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 创建进程时指定其父进程

Delphi中用socket解析域名获得ip地址

Delphi程序带参数运行

Delphi utf-8

Delphi网络英汉字典代码

Delphi tadoquery 中文使用说明

Delphi使用json解析调用淘宝ip地址库rest api 示例

Delphi中string与pansichar转换

Delphi ascii 码对照表

Delphi将文件删除至回收站

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



打赏

取消

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

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

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

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

评论

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