<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>SETENCODING</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">SETENCODING</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
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.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
None
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
International functions, System functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>SetEncoding(<i>scope_name,charset</i>)
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
GetEncoding, cfcontent, cfprocessingdirective, URLDecode, URLEncodedFormat; "Locales" in Chapter&#160;17, "Developing Globalized Applications," in ColdFusion MX Developer's Guide
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX: Added this function.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
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. 
</p>

<p>
For more information on character encoding, see the following web pages:
</p>
<ul>

<li>www.w3.org/International/O-charset.html</a> provides general information on character encoding and the web, and has several useful links.</li>

<li>www.iana.org/assignments/character-sets</a> is a complete list of character sets names used on the Internet, maintained by the Internet Assigned Numbers Authority.</li>

<li>java.sun.com/j2se/1.4.1/docs/guide/intl/encoding.doc.html</a> 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 SetEncoding charset parameter and other ColdFusion attributes and parameters. Java automatically converts standard IANA names to its internal names as needed.</li>
</ul>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;!--- 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. ---&gt;
&lt;cfcontent type=&quot;text/html; charset=big5&quot;&gt;
&lt;form action=&#39;#cgi.script_name#&#39; method=&#39;get&#39;&gt;
&lt;input name=&#39;xxx&#39; type=&#39;text&#39;&gt;
&lt;input name=&#39;yyy&#39; type=&#39;text&#39;&gt;
&lt;input type=&quot;Submit&quot; value=&quot;Submit&quot;&gt;
&lt;/form&gt;

&lt;cfif IsDefined(&quot;URL.xxx&quot;)&gt;
&lt;cfscript&gt;
   SetEncoding(&quot;url&quot;, &quot;big5&quot;); 
   WriteOutput(&quot;URL.XXX is &quot; &amp; URL.xxx &amp; &quot;&lt;br&gt;&quot;); 
   WriteOutput(&quot;URL.YYY is &quot; &amp; URL.yyy &amp; &quot;&lt;br&gt;&quot;);
    theEncoding = GetEncoding(&quot;URL&quot;);
    WriteOutput(&quot;The URL variables were decoded using &#39;&quot; &amp;
theEncoding &amp; &quot;&#39; encoding.&quot;); 
&lt;/cfscript&gt;
&lt;/cfif&gt;

</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="SCOPE_NAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">SCOPE_NAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

<ul>

<li>url</li>

<li>form</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="CHARSET">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">CHARSET</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>The character encoding in which text in the scope variables is encoded. The following list includes commonly used values:</p><ul>

<li>utf-8</li>

<li>iso-8859-1 </li>

<li>windows-1252</li>

<li>us-ascii</li>

<li>shift_jis</li>

<li>iso-2022-jp </li>

<li>euc-jp</li>

<li>euc-kr</li>

<li>big5</li>

<li>euc-cn</li>

<li>utf-16</li>
</ul>


  </td>
  </tr>
  </table>
</div>

  </body>
</html>
