Sample code for 30+ languages & platforms
Lianja

URL Encoding and Decoding

See more Encryption Examples

Demonstrates URL encoding and decoding.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

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

loSb = createobject("CkStringBuilder")
llSuccess = loSb.Append(s)

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

// Show the URL encoded string:
lcSEncoded = loSb.GetAsString()
? lcSEncoded

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

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

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

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

// Result is: Why a > b?


release loSb