| Contents > Developing ColdFusion MX Applications > Developing Globalized Applications > Handling data in ColdFusion MX > File data |
|
|
|
|
||
You use the cffile tag to write to and read from text files. By default, the cffile tag assumes that the text that you are reading, writing, copying, moving, or appending is in the JVM default file character encoding, which is typically the system default character encoding. For cffile action="Read", ColdFusion MX 6.1 also checks for a byte order mark (BOM) at the start of the file; if there is one, it uses the character encoding that the BOM specifies.
Note: To specify the JVM default file character encoding, use the -Dfile.encoding= switch in the JVM Arguments field of the ColdFusion MX Administrator Java and JVM Settings page.
Problems can arise if the file character encoding does not correspond to JVM character encoding, particularly if the number of bytes used for characters in one encoding does not match the number of bytes used for characters in the other encoding.
For example, assume that the JVM default file character encoding is ISO 8859-1, which uses a single byte for each character, and the file uses Shift-JIS, which uses a two-byte representation for many characters. When reading the file, the cffile tag treats each byte as an ISO 8859-1 character, and converts it into its corresponding two-byte Unicode representation. Because the characters are in Shift-JIS, the conversion corrupts the data, converting each two-byte Shift-JIS character into two Unicode characters.
To enable the cffile tag to correctly read and write text that is not encoded in the JVM default character encoding, you can pass the charset attribute to it. Specify as a value the character encoding of the data to read or write, as the following example shows:
<cffile action="read" charset="EUC-KR" file = "c:\web\message.txt" variable = "Message" >
|
|
||
| Contents > Developing ColdFusion MX Applications > Developing Globalized Applications > Handling data in ColdFusion MX > File data |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/i18n28.htm