Whatever message this page gives is out now! Go check it out!

GetEncoding

Last update:
May 18, 2026

Description

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

Returns

String; the character encoding of the specified scope.

Category

Function syntax

GetEncoding(scope_name)

See also

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. 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"> 

</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>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page