本文整理自网络,侵删。
//函数:
function ToUTF8Encode(str: string): string;
var
b: Byte;
begin
for b in BytesOf(UTF8Encode(str)) do
Result := Format('%s%s%.2x', [Result, '%', b]);
end;
//测试:
var
str: string;
begin
str := '三生有幸网';
str := ToUTF8Encode(str);
ShowMessage(str); //%E4%B8%87%E4%B8%80
end;
相关阅读 >>
Delphi 解决timage无法在窗体resize时改变canvas的大小
Delphi twebbrowser出现 method pastehtml not supported by automation object 解决方法
Delphi datasnap 上传/下载大文件(本demo以图传片文件为例)
更多相关阅读请进入《Delphi》频道 >>