Delphi escape/unescape编码


本文整理自网络,侵删。

 //作者0ak/lyris 
function Escape(Str: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(Str) do
Result := Result + '%' + IntToHex(Ord(Str[I]), 2);
end;
function CharToInt(C: char): Integer;
begin
if ord((C)) >= 65 then
Result := 10 + ord(C) - 65
else
Result := ord(C) - 48;
end;
function HexToInt(Str: string): longint;
var
I: Integer;
p1: array[0..1] of Char;
begIn
Result := 0;
Str := Trim(Str);
for I := 1 to length(Str) do
begIn
StrPcopy(p1, Copy(Str, I, 1));
Result := Result * 16 + CharToInt(p1[0]);
end;
end;
function unescape(Str: string): string;
begin
Result := '';
while Length(Str) >= 3 do
begin
Str[1] := '#';
Result := Result + Chr(HexToInt(Copy(Str, 1, 3)));
Delete(Str, 1, 3);
end;
end;

相关阅读 >>

Delphi windows 编程[16] - 添加与删除菜单项:getmenu、appendmenu、deletemenu、drawmenubar

Delphi延时4种方法

isleapyear:返回给定的年份是否是闰年

Delphi获取当前计算机所有盘符

Delphi 快速检测是否联网

Delphi xe 打开andorid gps设置

Delphixe4 版本中,已针对移动平台 引入了 arc 模型

Delphi 判断文本文件是否utf-8编码

idhttp使用时内存猛增,如何解决

python4Delphi 示例应用程序在 Delphi 应用程序中运行简单的 python 脚本

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



打赏

取消

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

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

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

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

评论

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