# URLEncodedFormat

Returns a URL-encoded string. Spaces are replaced with + and all non-alphanumeric characters with equivalent hexadecimal escape sequences. This function enables you to pass arbitrary strings within a URL, because ColdFusion automatically decodes all URL parameters that are passed to the template.

See also URLDecode.

### Syntax

    URLEncodedFormat(string)

##### string

String being URL encoded.

### Usage

URL encoding refers to a data format where all high ASCII and non-alphanumeric characters are encoded using a percent sign followed by the two character hexadecimal representation of the character code. For example, a character with code 129 will be encoded as %81. In addition, spaces can be encoded using the plus sign (+).

Query strings in HTTP are always URL-encoded.

URL-encoded strings can be created using the URLEncodedFormat function.

### Examples

    <!--- This example shows URLEncodedFormat --->
    <HTML>
    <HEAD>
    <TITLE>
    URLEncodedFormat Example
    </TITLE>
    </HEAD>

    <BODY BGCOLOR=silver>
    <H3>URLEncodedFormat Example</H3>

    <CFIF IsDefined("url.myExample")>
    <P>The url variable url.myExample has been passed from the
    previous link ... its value is:
    <BR>"<CFOUTPUT>#url.myExample#</CFOUTPUT>"
    </CFIF>

    <P>This function returns a URL encoded string, making it
    safe to pass strings through a URL.
    <CFSET s =
       "My url-encoded string has special characters & other stuff">
    <P>
    <A HREF=
       "urlencodedformat.cfm?myExample=<CFOUTPUT>#URLEncodedFormat(s)#
    </CFOUTPUT>">Click me</A>

    </BODY>
    </HTML>