Delphi ActiveX
Delphi ActiveX
URL Encoding and Decoding
Demonstrates URL encoding/decoding using the HTTP convenience methods.Chilkat Delphi ActiveX Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
http: TChilkatHttp;
s: WideString;
encoded: WideString;
decoded: WideString;
begin
http := TChilkatHttp.Create(Self);
s := 'Hello World! 100% sure.';
encoded := http.UrlEncode(s);
Memo1.Lines.Add('URL encoded: ' + encoded);
// Space → %20
// ! → %21
// % → %25
decoded := http.UrlDecode(encoded);
Memo1.Lines.Add('URL decoded: ' + decoded);
// Output:
// URL encoded: Hello%20World%21%20100%25%20sure.
// URL decoded: Hello World! 100% sure.
end;