URLCODETOGB
来源:互联网 发布:"淘宝差评师曝光平台 编辑:程序博客网 时间:2024/05/18 07:12
function
URLDecode(
const
S:
string
):
string
;
var
Idx:
Integer
;
Hex:
string
;
Code:
Integer
;
begin
Result :=
''
;
Idx :=
1
;
while
Idx <= Length(S)
do
begin
case
S[Idx]
of
'%'
:
begin
if
Idx <= Length(S) -
2
then
begin
Hex := S[Idx+
1
] + S[Idx+
2
];
Code := SysUtils
.
StrToIntDef(
'$'
+ Hex, -
1
);
Inc(Idx,
2
);
end
else
Code := -
1
;
if
Code = -
1
then
raise
SysUtils
.
EConvertError
.
Create(
'Invalid hex digit in URL'
);
Result := Result + Chr(Code);
end
;
'+'
:
Result := Result +
' '
else
Result := Result + S[Idx];
end
;
Inc(Idx);
end
;
end
;
function
URLEncode(
const
S:
string
;
const
InQueryString:
Boolean
):
string
;
var
Idx:
Integer
;
begin
Result :=
''
;
for
Idx :=
1
to
Length(S)
do
begin
case
S[Idx]
of
'A'
..
'Z'
,
'a'
..
'z'
,
'0'
..
'9'
,
'-'
,
'_'
,
'.'
:
Result := Result + S[Idx];
' '
:
if
InQueryString
then
Result := Result +
'+'
else
Result := Result +
'%20'
;
else
Result := Result +
'%'
+ SysUtils
.
IntToHex(Ord(S[Idx]),
2
);
end
;
end
;
end
;
阅读全文
0 0
- URLCODETOGB
- serialVersionUID的作用
- Modbus协议———功能码及格式简述
- 当yuv player30天过期了之后,怎样注册
- Linux知识库
- 阿里云前端周刊
- URLCODETOGB
- JavaScript中document对象取得的关于窗口宽高和滚动值的属性列表
- 开始拥有属于的自己的博客-20170614
- 串口数据的接收
- 使用 ajax+php system函数,控制 linux执行 ls 命令,显示linux服务器上的文件
- 内核源码--------set_task_stack_end_magic(&init_task)
- 关于IE7的display:inline-block失效问题
- 欢迎使用CSDN-markdown编辑器
- 爬百度贴吧任一帖子