Tcl
Tcl
URL Encoding and Decoding
See more Encryption Examples
Demonstrates URL encoding and decoding.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# To URL encoding a string:
set s "Why a > b?"
set sb [new_CkStringBuilder]
set success [CkStringBuilder_Append $sb $s]
# URL encode the string.
CkStringBuilder_Encode $sb "url" "utf-8"
# Show the URL encoded string:
set sEncoded [CkStringBuilder_getAsString $sb]
puts "$sEncoded"
# The result is: Why%20a%20%3E%20b%3F
# If you prefer "+" instead of "%20" for SPACE chars:
set numReplaced [CkStringBuilder_Replace $sb "%20" "+"]
puts [CkStringBuilder_getAsString $sb]
# Output is: Why+a+%3E+b%3F
# To decode:
CkStringBuilder_Decode $sb "url" "utf-8"
puts [CkStringBuilder_getAsString $sb]
# Result is: Why a > b?
delete_CkStringBuilder $sb