Returns an url-encoded string with respect to charset.
urlEncode(string [, charset] [, force])
→ returns string
string.urlEncode([charset] [, force])
utf-8
utf-8
iso-8859-1
windows-1252
us-ascii
shift_jis
iso-2022-jp
euc-jp
euc-kr
big5
euc-cn
utf-16
true
Encode string with special chars for use in url
urlEncode('Apples → Äpfel','utf-8')
Expected Result: Apples+%E2%86%92+%C3%84pfel
Same string, different charset
urlEncode('Apples → Äpfel','ASCII')
Expected Result: Apples+%3F+%3Fpfel
vocab = [{
apples: {
en: 'apples',
de: 'Äpfel',
da: 'æble',
el: 'μήλο'
}
}];
writeOutput(urlEncode(vocab.toString(),'utf-8'));
Expected Result: %5B%7BAPPLES%3D%7B%7BEL%3D%7B%CE%BC%CE%AE%CE%BB%CE%BF%7D%2C+EN%3D%7Bapples%7D%2C+DA%3D%7B%C3%A6ble%7D%2C+DE%3D%7B%C3%84pfel%7D%7D%7D%7D%5D
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.