上海应该是C9CF BAA3
function strtohex(str:string):string;
var i:integer;
begin
for i:=1 to length(str) do
begin
result:=result+inttohex(ord(str[i]),2);
end;
end;
function hextostr(hex:string):string;
var i,j,k:integer;
begin
k:=length(hex) div 2;
for i:=1 to k do
begin
case hex[2*i-1] of
'0'..'9':j:=strtoint(hex[2*i-1]);
'a'..'f':j:=ord(hex[2*i-1])-87;
'A'..'F':j:=ord(hex[2*i-1])-55;
end;
case hex[2*i] of
'0'..'9':j:=j*16+strtoint(hex[2*i]);
'a'..'f':j:=j*16+ord(hex[2*i])-87;
'A'..'F':j:=j*16+ord(hex[2*i])-55;
end;
result:=result+chr(j);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(strtohex('上海'));
showmessage(hextostr('C9CFBAA3'));
end;