Sample code for 30+ languages & platforms
Xbase++

URL Encoding and Decoding

See more Encryption Examples

Demonstrates URL encoding and decoding.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL s
LOCAL oSb
LOCAL cSEncoded
LOCAL nNumReplaced

nSuccess := 0

//  To URL encoding a string:
s := "Why a > b?"

oSb := CreateObject("Chilkat.StringBuilder")
nSuccess := oSb:Append(s)

//  URL encode the string.
oSb:Encode("url", "utf-8")

//  Show the URL encoded string:
cSEncoded := oSb:GetAsString()
? cSEncoded

//  The result is:  Why%20a%20%3E%20b%3F

//  If you prefer "+" instead of "%20" for SPACE chars:
nNumReplaced := oSb:Replace("%20", "+")
? oSb:GetAsString()

//  Output is:   Why+a+%3E+b%3F

//  To decode:
oSb:Decode("url", "utf-8")
? oSb:GetAsString()

//  Result is: Why a > b?

oSb:destroy()