Thread: TIdHTTP.Post ?
View Single Post
  #4  
Old 12-02-2010, 06:32 PM
Jeffijoe Jeffijoe is offline
Senior Member
 
Join Date: Nov 2009
Posts: 149
Default

Quote:
Originally Posted by MrBaseball34 View Post
Use this URLEncode function, it is much smaller:
Code:
function URLEncode(const ASrc: string): string;
var
  i: Integer;
const
  UnsafeChars = ['*', '#', '%', '<', '>', ' ','[',']'];  {do not localize}
begin
  Result := '';    {Do not Localize}
  for i := 1 to Length(ASrc) do
  begin
    if (ASrc[i] in UnsafeChars) or (not (ord(ASrc[i])in [33..128])) then
    begin {do not localize}
      Result := Result + '%' + IntToHex(Ord(ASrc[i]), 2);  {do not localize}
    end
    else
    begin
      Result := Result + ASrc[i];
    end;
  end;
end;

Hi MrBaseBall,

Thanks for your reply, however I got my code fixed, and I wrote a class to do it for me. Thanks anyway.

What does that function do?
Reply With Quote