procedure TForm1.FormCreate(Sender: TObject); begin ShowMessage(HexStr(AnsiToUtf8('中国'))); end;function TForm1.HexStr(s: string): string; var p: ^Byte; begin p := Pointer(PChar(s)); while p^ <> 0 do begin Result := Result + '%' + IntToHex(p^, 2); Inc(p); end; end;
begin
ShowMessage(HexStr(AnsiToUtf8('中国')));
end;function TForm1.HexStr(s: string): string;
var
p: ^Byte;
begin
p := Pointer(PChar(s));
while p^ <> 0 do
begin
Result := Result + '%' + IntToHex(p^, 2);
Inc(p);
end;
end;