我是这样做的。
function AnsiToUnicode(Ansi: string): string;
var
s:string;
i:integer;
j,k:string[2];
a:array [1..1000] of char;
begin
try
s:='';
StringToWideChar(Ansi,@(a[1]),500);
i:=1;
while ((a<>#0) or (a[i+1]<>#0)) do begin
j:=IntToHex(Integer(a),2);
k:=IntToHex(Integer(a[i+1]),2);
s:=s+k+j;
i:=i+2;
end;
Result:=s;
except
Result:='';
end;
end;
function ReadHex(AString: string): integer;
begin
try
Result:=StrToInt('$'+AString);
except
Result:=0;
end;
end;
function UnicodeToAnsi(Unicode: string): string;
var
s:string;
i:integer;
j,k:string[2];
begin
i:=1;
s:='';
try
while i<length(unicode) do
begin
j:=Copy(Unicode,i+2,2);
k:=Copy(Unicode,i,2);
i:=i+4;
s:=s+Char(ReadHex(j))+Char(ReadHex(k));
end;
if s<>'' then
s:=WideCharToString(PWideChar(s+#0#0#0#0))
else
s:='';
Result:=s;
except
Result:='';
end;
end;