URLEncode

encode an url

URLEncode( string [, charset [, force ] ] )

Returns: String

Argument Description Default
string
string, required
charset
string, optional

The World Wide Web Consortium Recommendation states that UTF-8 should be used as per https://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars

  • Using different charsets may cause incompatibilities with other systems.

utf-8

force
boolean, optional

If false, then the string will not be encoded if it does not contain unsafe characters.

true

Examples

url_string = "https://dev.lucee.org/t/welcome-to-lucee-dev/2064";
dump(URLEncode(url_string)); // https%3A%2F%2Fdev%2Elucee%2Eorg%2Ft%2Fwelcome%2Dto%2Dlucee%2Ddev%2F2064

See also