Sample code for 30+ languages & platforms
PureBasic

URL Encoding and Decoding

Demonstrates URL encoding/decoding using the HTTP convenience methods.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

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

    encoded.s = CkHttp::ckUrlEncode(http,s)
    Debug "URL encoded: " + encoded

    ; Space → %20
    ; ! → %21
    ; % → %25

    decoded.s = CkHttp::ckUrlDecode(http,encoded)
    Debug "URL decoded: " + decoded

    ; Output:

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


    CkHttp::ckDispose(http)


    ProcedureReturn
EndProcedure