delphi将字符串转换成UTF8编码的函数


本文整理自网络,侵删。

 //函数:
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 解决android 9上无法使用http协议

Delphi 设置webbrowser 代理服务器 与 useragent

Delphi 调用批处理

Delphi日期函数、日期加减

Delphi获取星期函数

Delphi 如何把程序钉到windows7任务栏(修正版)

Delphi 代码查询一个json ip 地址的归属地

Delphi10.3读取json数据

Delphi jpeg图片压缩

Delphi如何过xp的防火墙而不被拦截

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...