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.

setEncoding(scope_name, charset) → returns void

Argument Reference for the setEncoding function


Required: Yes


Required: Yes
The character encoding in which text in the scope
variables is encoded. Values:
  • utf-8
  • iso-8859-1
  • windows-1252
  • us-ascii
  • shift_jis
  • iso-2022-jp
  • euc-jp
  • euc-kr
  • big5
  • euc-cn
  • utf-16

Examples sample code invoking the setEncoding function

Script Example

<!--- 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); 

Fork me on GitHub