D10下:
function ToUTF8Encodes(str: UTF8String): string;
var
b: Byte;
begin
for b in BytesOf(str) do
Result := Format('%s%%%.2x', [Result, b]);
end;
调用:
procedure TForm1.btn13Click(Sender: TObject);
begin
ShowMessage(ToUTF8Encodes('中国'));