Standard URL encode function?

Another simple way of doing this is to use the HTTPEncode function in the HTTPApp unit - very roughly

Uses 
  HTTPApp;

function URLEncode(const s : string) : string;
begin
  result := HTTPEncode(s);
end

HTTPEncode is deprecated in Delphi 10.3 - 'Use TNetEncoding.URL.Decode'

Uses
  NetEncoding;

function URLEncode(const s : string) : string;
begin
  result := TNetEncoding.URL.Encode(s);
end

Look at indy IdURI unit, it has two static methods in the TIdURI class for Encode/Decode the URL.

uses
  IdURI;

..
begin
  S := TIdURI.URLEncode(str);
//
  S := TIdURI.URLDecode(str);
end;

Tags:

Delphi