// 将字符转化成Unicode 
function AnsiToUnicode(Ansi: string):string;
var
s:string;
i:integer;
j,k:string[2];
a:array [1..1000] of char;
begin
s:='';
StringToWideChar(Ansi,@(a[1]),500);
i:=1;
while ((a[i]<>#0) or (a[i+1]<>#0)) do begin
j:=IntToHex(Integer(a[i]),2);
k:=IntToHex(Integer(a[i+1]),2);
s:=s+k+j;
i:=i+2;
end;
Result:=s;
end;

// 将Unicode转化成字符
function ReadHex(AString:string):integer;
begin
Result:=StrToInt('$'+AString)
end;

function UnicodeToAnsi(Unicode: string):string;
var
s:string;
i:integer;
j,k:string[2];
begin
i:=1;
s:='';
while i< if end; s:="s+Char(ReadHex(j))+Char(ReadHex(k));" i:="i+4;" k:="Copy(Unicode,i,2);" j:="Copy(Unicode,i+2,2);" begin do>'' then
s:=WideCharToString(PWideChar(s+#0#0#0#0))
else
s:='';
Result:=s;
end;
posted on 2009-06-17 15:36  on_road  阅读(653)  评论(0编辑  收藏  举报