View comments | RSS feed

GetEncoding

Description

Returns the encoding (character set) of the Form or URL scope.

Returns

String; the character encoding of the specified scope.

Category

International functions, System functions

Function syntax

GetEncoding(scope_name)

See also

SetEncoding, cfcontent, cfprocessingdirective, URLDecode, URLEncodedFormat

History

ColdFusion MX: Added this function.

Parameters

Parameter Description

scope_name

  • Form
  • URL.

Usage

Use this function to determine the character encoding of the URL query string or the fields of a form that was submitted to the current page. The default encoding, if none has been explicitly set, is UTF-8.

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

Example

<!--- This example sends the contents of two fields and interprets them as
      big5 encoded text. --->
<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">
</form>

<cfif IsDefined("URL.xxx")>
<cfscript>
   SetEncoding("url", "big5"); 
   WriteOutput("URL.XXX is " & URL.xxx & "<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); 
</cfscript>
</cfif>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


kpolo said on Jul 7, 2005 at 4:48 PM :
Compared with the scripts provided in ''setEncoding', it appends the following line

WriteOutput("The encoding is " & theEncoding);

but in the beginning comment, it doesn't indicate that "Note that the form fields are received as URL variables because the form uses the GET method." as “setEncoding" does.

Why not combine them together as one script example and quote it in both sections?
ASandstrom said on Jul 8, 2005 at 8:04 AM :
To kpolo: Nice idea! I've entered this as a doc enhancement (#60511) so that it will be changed in the next release of ColdFusion.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000477.htm