urlEncode
Returns an url-encoded string with respect to charset.
urlEncode(string [, charset] [, force]) → returns string
Member Function Syntax
string.urlEncode([charset] [, force])
This function requires Lucee. Not supported on Adobe ColdFusion, etc.
Argument Reference
string string Required
charset string
Default: utf-8
utf-8
The character encoding in which the string will be encoded.
Values:
utf-8iso-8859-1windows-1252us-asciishift_jisiso-2022-jpeuc-jpeuc-krbig5euc-cnutf-16
force boolean
Default: true
true
Examples Sample code invoking the urlEncode function
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
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/urlencode