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 edit控制字居中,居左,居右

Delphi 如何确定活动桌面是否已启用

Delphi 百万次重复调用字符分割函数,不耗内存用法

Delphi 加壳原理与简单实现加壳

Delphi 设置开机自动启动函数

Delphi之autorun(复制自身+循环扫描)

Delphi 有授权许可的字符串拷贝函数源码

Delphi kbmmw sampleservice/sampleclient方式传输数据集

Delphi 中文姓名 合法性检查

Delphi yesterday、today、tomorrow - 昨天、今天、明天

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



打赏

取消

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

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

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

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

评论

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

    正在狠努力加载,请稍候...