Determining the page encoding of server output

Before ColdFusion can return a response to the client, it must determine the encoding to use for the data in the response. By default, ColdFusion returns character data using the Unicode UTF-8 format.

ColdFusion pages (.cfm pages) default to using the Unicode UTF-8 format for the response, even if you include the HTML meta tag in the page. Therefore, the following example doesnot modify the character set of the response:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type"  
    content="text/html;  
    charset="Shift_JIS"> 
</head> 
...

In this example, the response still uses the UTF-8 character set. Use the cfcontent tag to set the output character set.

However, within a ColdFusion page you can use the cfcontent tag to override the default character encoding of the response. Use the type attribute of the cfcontent tag to specify the MIME type of the page output, including the character set, as follows:

<cfcontent type="text/html charset=EUC-JP"> 
Note: ColdFusion also provides attributes that let you specify the encoding of specific elements, such as HTTP requests, request headers, files, and mail messages. For more information, see Tags and functions for controlling character encoding and Handling data in ColdFusion.

The rest of this chapter describes ColdFusion tags and functions that you use for globalization, and discusses specific globalization issues.