Sample code for 30+ languages & platforms
C

URL Encoding and Decoding

Demonstrates URL encoding/decoding using the HTTP convenience methods.

Chilkat C Downloads

C
#include <C_CkHttp.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    const char *s;
    const char *encoded;
    const char *decoded;

    http = CkHttp_Create();

    s = "Hello World! 100% sure.";

    encoded = CkHttp_urlEncode(http,s);
    printf("URL encoded: %s\n",encoded);

    //  Space → %20
    //  ! → %21
    //  % → %25

    decoded = CkHttp_urlDecode(http,encoded);
    printf("URL decoded: %s\n",decoded);

    //  Output:

    //  URL encoded: Hello%20World%21%20100%25%20sure.
    //  URL decoded: Hello World! 100% sure.


    CkHttp_Dispose(http);

    }