Accessibility

TechNote (Archived)

Set encoding in ColdFusion MX pages

Character encoding in ColdFusion pages

Dreamweaver uses meta tags to specify document encoding as defined in the page properties. However, these meta tags are disregarded when you are working with ColdFusion MX pages. ColdFusion MX displays pages using the Unicode UTF-8 regardless of what is specified in the document encoding meta tags.

The CFCONTENT tag should be used instead of meta tags to set the document encoding of the generated page output:

<cfcontent type="text/html; charset=iso-8859-1">

Note: In this example, the CFCONTENT tag is changing the character encoding from the default of UTF-8 to iso-8859-1. To customize this code, replace iso-8859-1 with the desired encoding setting.

Character encoding for submitted data

The CFCONTENT tag only applies to the final output displayed by the browser. This does not cover data submitted from your pages with form or url variables. By default, ColdFusion MX reads these variables as Western (Latin 1). If your web application cannot handle this encoding, you need to use ColdFusion functions that change this setting.

The setEncoding() function should be called before any code that references these form or url variables:

setEncoding("URL", "UTF-8");

or

setEncoding("Form", "UTF-8");

Note: In this example, the default encoding of iso-8859-1 for form and url variables is converted to UTF-8. To customize this code, replace references to UTF-8 with the desired encoding setting.

The purpose of these tags and functions

The type attribute of the CFCONTENT tag contains the MIME type and encoding name to be used when the page is returned to the browser. This tag is used to change the document encoding of the page. The CFCONTENT tag should be used in place of meta tags when the desired document encoding is not UTF-8.

The setEncoding function sets the character encoding of Form and URL scope variable values. This function is optional and need only be used if the character set used in URLs or form input is in an encoding setting other than Latin-1 encoding (ISO-8859-1).

Additional information

For more information on document encoding in ColdFusion MX, please read Internationalizing ColdFusion MX applications. For ColdFusion MX related articles and tutorials, please visit theColdFusion Development Center. For ColdFusion support information, please visit the ColdFusion Support Center.

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support

Document Details

ID:tn_16597
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox
Database:DB2
Informix
MySQL
Oracle
SQL Server
Sybase
MS Access

Products Affected:

dreamweaver