SetEncoding

Description

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

Return value

None

Category

Display and formatting functions, System functions

Syntax

SetEncoding(scope_name,charset) 

See also

cfcontent, cfprocessingdirective, URLDecode, URLEncodedFormat

Parameters

Parameter Description
scope_name
  • url
  • form
charset
A Java character set name for the file contents. The following values are typically used:
  • EUC-JP
  • EUC-K
  • ISO-8859-1
  • SHIFT-JIS
  • UTF-8 (Default)
  • UTF-16
  • US-ASCII
  • UTF-16BE
  • UTF-16LE
For a list of character sets, see:
http://www.w3.org/International/O-charset-lang.html

Usage

Use this tag when the character set of the input to a form or the character set of a URL is not in Latin-1 encoding. For example, Traditional Chinese characters are in Big5 encoding. Before getting URL or FORM parameters, call this function (typically, in the application.cfml page) to set the encoding and avoid getting incorrect parameter values.

For more information, see: http://www.iana.org/assignments/character-sets.

The following example shows how you could process form data such as the following:

<form action='process.cfm' method='get'>
<input name='xxx' type='text'>
<input name='yyy' type='text'>
</form>

Example

<cfoutput> 
  setEncoding("url", "big5"); 
  writeoutput(URL.xxx); 
  writeoutput(URL.yyy); 
</cfoutput> 

Comments