function URLDecode(psSrc: string): string;
var
i: Integer;
ESC: string[2];
CharCode: integer;
begin
Result := ''; { do not localize }
psSrc := StringReplace(psSrc, '+', ' ', [rfReplaceAll]); {do not localize}
i := 1;
while i <= Length(psSrc) do
begin
if psSrc <> '%' then { do not localize }
begin {do not localize}
Result := Result + psSrc
end
else
begin
Inc(i);
ESC := Copy(psSrc, i, 2);
Inc(i, 1);
try
CharCode := StrToInt('$' + ESC); {do not localize}
if (CharCode > 0) and (CharCode < 256) then
Result := Result + Char(CharCode);
except
end;
end;
Inc(i);
end;
end;
function URLEncode(const psSrc: string): string;
const
UnsafeChars = ' *#%<>'; {do not localize}
var
i: Integer;
begin
Result := ''; { do not localize }
for i := 1 to Length(psSrc) do
begin
if (Pos(psSrc, UnsafeChars) > 0) or (psSrc >= #$80) then
begin
Result := Result + '%' + IntToHex(Ord(psSrc), 2); {do not localize}
end
else
begin
Result := Result + psSrc;
end;
end;
end;