Name

URLEncodedFormat

Synopsis

URLEncodedFormat(string)

Encodes strings that otherwise cause errors when passed as URLs. URLEncodedFormat( ) replaces nonalphanumeric characters with their equivalent hexadecimal escape sequences. ColdFusion automatically decodes any URL-escaped strings it encounters. The following example creates a URL-encoded hyperlink from a string containing spaces and nonalphanumeric characters:

<CFSET TheDate = "08/15/1998">
<CFSET ItemID = "123456">
<CFSET Customer = "Caroline Smith">

Click on the link below to check-out:<BR>
<P><CFOUTPUT>
<A HREF="http://www.myserver.com/index.cfm?TheDate=#UrlEncodedFormat(TheDate)#&
ItemID=#UrlEncodedFormat(ItemID)#&Customer=#UrlEncodedFormat(Customer)#">Check-out
</A>
</CFOUTPUT>

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.