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
(C) URL Encoding and DecodingDemonstrates URL encoding and decoding.
#include <C_CkStringBuilder.h> void ChilkatSample(void) { const char *s; HCkStringBuilder sb; BOOL success; const char *sEncoded; int numReplaced; // 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); printf("%s\n",sEncoded); // The result is: Why%20a%20%3E%20b%3F // If you prefer "+" instead of "%20" for SPACE chars: numReplaced = CkStringBuilder_Replace(sb,"%20","+"); printf("%s\n",CkStringBuilder_getAsString(sb)); // Output is: Why+a+%3E+b%3F // To decode: CkStringBuilder_Decode(sb,"url","utf-8"); printf("%s\n",CkStringBuilder_getAsString(sb)); // Result is: Why a > b? CkStringBuilder_Dispose(sb); } |
© 2000-2023 Chilkat Software, Inc. All Rights Reserved.