大哥教下小弟,指定字符转换 Unicode 编码
着是 JScript 8.0的原码 我想转到 delphi 上用
function charCodeAtTest(n){
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Initialize variable.
var n; //Declare variable.
n = str.charCodeAt(n - 1); //Get the Unicode value of the
// character at position n.
return(n); //Return the value.
}
着是 JScript 8.0的原码 我想转到 delphi 上用
function charCodeAtTest(n){
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Initialize variable.
var n; //Declare variable.
n = str.charCodeAt(n - 1); //Get the Unicode value of the
// character at position n.
return(n); //Return the value.
}
MultiByteToWideChar
这个转换吧
var
str1:string;
str2:widestring;
pp:pbyte;
begin
str1:='我';str2:=widestring(str1);pp:=@str2[1];
showmessage(inttostr(pp^));
inc(pp);
showmessage(inttostr(pp^));
end;指定的字符强制转换成widestring,然后用指针去读每个字节的内容.记住unicode是两字节的
var s:string;
i:integer;
t:widestring;
h,l:byte;
begin
s:='';
t:=widestring(Ansi);
for i:=1 to length(t) do
begin
h:=hi(ord(t[i]));
l:=lo(ord(t[i]));
s:=s+inttohex(h,2)+inttohex(l,2);
end;
Result:=s;
end;这个函数,可以转换二十几个国家的语言,没任何问题,我只试了二十几个国家的语言....
返回的字符串是以16 进制表示,