Sets the character encoding (character set) of Form and URL scope variable values; used when the character encoding of the input to a form, or the character encoding of a URL, is not in UTF-8 encoding.



Function syntax


See also

GetEncoding, cfcontent, cfprocessingdirective, URLDecode, URLEncodedFormat; Locales in the Developing ColdFusion Applications


ColdFusion MX: Added this function.





  • url

  • form


The character encoding in which text in the scope variables is encoded. 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


Use this function when the character encoding of the input to a form or the character encoding of a URL is not in UTF-8 encoding. For example, Traditional Chinese characters are often in Big5 encoding. This function resets URL and Form variables, so you should call it before using these variables (typically, in the Application.cfm page or Application.cfc file). Calling this function first also avoids interpreting the characters of the variables incorrectly.

For more information on character encoding, see the following web pages:

  • provides general information on character encoding and the web, and has several useful links.

  • is a complete list of character sets names used on the Internet, maintained by the Internet Assigned Numbers Authority.

  • lists the character encoding that Java 1.4.1, and therefore the default ColdFusion configuration, can interpret. If you use a JVM that does not conform to the Sun Java 2 Platform, Standard Edition, v 1.4.1, the supported locales may differ. The list uses Java internal names, not the IANA character encoding names that you normally use in the SetEncodingcharset parameter and other ColdFusion attributes and parameters. Java automatically converts standard IANA names to its internal names as needed.


<!--- This example sends and interprets the contents of two fields as 
        big5 encoded text. Note that the form fields are received as URL variables 
        because the form uses the GET method. ---> 
<cfcontent type="text/html; charset=big5"> 
<form action='#cgi.script_name#' method='get'> 
<input name='xxx' type='text'> 
<input name='yyy' type='text'> 
<input type="Submit" value="Submit"> 
<cfif IsDefined("")> 
    SetEncoding("url", "big5");  
    WriteOutput("URL.XXX is " & & "<br>");  
    WriteOutput("URL.YYY is " & URL.yyy & "<br>"); 
theEncoding = GetEncoding("URL"); 
     WriteOutput("The URL variables were decoded using '" & 
    theEncoding & "' encoding.");  
WriteOutput("The encoding is " & theEncoding);