Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) URL Encoding and DecodingDemonstrates URL encoding and decoding.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, StringBuilder; ... procedure TForm1.Button1Click(Sender: TObject); var s: PWideChar; sb: HCkStringBuilder; success: Boolean; sEncoded: PWideChar; numReplaced: Integer; begin // To URL encoding a string: s := 'Why a > b?'; sb := CkStringBuilder_Create(); success := CkStringBuilder_Append(sb,s); // URL encode the string. CkStringBuilder_Encode(sb,'url','utf-8'); // Show the URL encoded string: sEncoded := CkStringBuilder__getAsString(sb); Memo1.Lines.Add(sEncoded); // The result is: Why%20a%20%3E%20b%3F // If you prefer "+" instead of "%20" for SPACE chars: numReplaced := CkStringBuilder_Replace(sb,'%20','+'); Memo1.Lines.Add(CkStringBuilder__getAsString(sb)); // Output is: Why+a+%3E+b%3F // To decode: CkStringBuilder_Decode(sb,'url','utf-8'); Memo1.Lines.Add(CkStringBuilder__getAsString(sb)); // Result is: Why a > b? CkStringBuilder_Dispose(sb); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.