Visual FoxPro
Visual FoxPro
URL Encoding and Decoding
See more Encryption Examples
Demonstrates URL encoding and decoding.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL s
LOCAL loSb
LOCAL lcSEncoded
LOCAL lnNumReplaced
lnSuccess = 0
* To URL encoding a string:
s = "Why a > b?"
loSb = CreateObject('Chilkat.StringBuilder')
lnSuccess = 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