function UrlEncode(CONST URL: string): string; { It also fixes the Indy encoding issue. http://stackoverflow.com/questions/5708863/indy-is-altering-the-binary-data-in-my-url }
VAR
i: Integer;
CONST
UnsafeChars = ['*', '#', '%', '<', '>', ' ', '[', ']', '\', '@'];
begin
Result := '';
for i := 1 to Length(URL) DO
if (URL[i]> #32)
AND (URL[i]<= #128) { € = char #128}
AND (NOT CharInSet(URL[i], UnsafeChars))
then Result := Result + URL[i]
else Result := Result + '%' + IntToHex(Ord(URL[i]), 2);
end;
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END