Unicode C++
Unicode C++
URL Encoding and Decoding
See more Encryption Examples
Demonstrates URL encoding and decoding.Chilkat Unicode C++ Downloads
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
bool success = false;
// To URL encoding a string:
const wchar_t *s = L"Why a > b?";
CkStringBuilderW sb;
success = sb.Append(s);
// URL encode the string.
sb.Encode(L"url",L"utf-8");
// Show the URL encoded string:
const wchar_t *sEncoded = sb.getAsString();
wprintf(L"%s\n",sEncoded);
// The result is: Why%20a%20%3E%20b%3F
// If you prefer "+" instead of "%20" for SPACE chars:
int numReplaced = sb.Replace(L"%20",L"+");
wprintf(L"%s\n",sb.getAsString());
// Output is: Why+a+%3E+b%3F
// To decode:
sb.Decode(L"url",L"utf-8");
wprintf(L"%s\n",sb.getAsString());
// Result is: Why a > b?
}