URLEncodedFormat example
Following is an example to show the usage of the function "URLEncodedFormat".
Description: Generates an URL-encoded string. For example, it replaces spaces with %20, and non-alphanumeric characters with equivalent hexadecimal escape sequences.
Returns: A copy of a string, URL-encoded.
syntax: URLEncodedFormat(string [, charset ])
string: A string or a variable that contains a string.
charset: The character encoding in which the string is encoded. Optional.
The following list includes commonly used values:
* utf-8 * iso-8859-1 * windows-1252 * us-ascii * shift_jis * iso-2022-jp * euc-jp * euc-kr * big5 * euc-cn * utf-16
Here is a simple example:
<br><cfoutput>The URLEncodedFormat of "Adobe Cold Fusion 8" is <br>"#enc#".
</cfoutput>
<br><cfset enc = URLEncodedFormat("JRUN&ColdFusion 8.0.1")>
<cfoutput>The URLEncodedFormat of "JRUN&ColdFusion 8.0.1" is <br>"#enc#".
</cfoutput>
Another example follows:
<cfif IsDefined("url.myExample")>
<p>The url variable url.myExample was passed from the previous link ...
its value is:
<br><b>"<cfoutput>#url.myExample#</cfoutput>"</b>
</cfif>
<p>This function returns a URL encoded string.
<cfset s = "My url-encoded string has special characters & other stuff">
<p> <A HREF = "urlencodedformat.cfm?myExample=<cfoutput>#URLEncodedFormat(s)#
</cfoutput>">Click me</A>
You can download the code using the download button.
