String encoding conversion
20 July 2007 10:42 (EST)
You can use following code to convert string encoding using Java library:
Every implementation of the Java platform is required to support the following standard charsets. Consult Java release documentation for your implementation to see if any other charsets are supported. Following charsets are supported with Java 2 Platform SE v1.4.2:
US-ASCII = Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set
ISO-8859-1 = ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
UTF-8 = Eight-bit UCS Transformation Format
UTF-16BE = Sixteen-bit UCS Transformation Format, big-endian byte order
UTF-16LE = Sixteen-bit UCS Transformation Format, little-endian byte order
UTF-16 = Sixteen-bit UCS Transformation Format, byte order
<cfset oCharset = createObject("java","java.nio.charset.Charset") />
<cfset fromCharSet = oCharset.forName('utf-8') />
<cfset toCharSet = oCharset.forName('iso-8859-1') />
<cfset b = toCharSet.decode(fromCharSet.encode(q)).ToString() />
<cfset fromCharSet = oCharset.forName('utf-8') />
<cfset toCharSet = oCharset.forName('iso-8859-1') />
<cfset b = toCharSet.decode(fromCharSet.encode(q)).ToString() />
US-ASCII = Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set
ISO-8859-1 = ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
UTF-8 = Eight-bit UCS Transformation Format
UTF-16BE = Sixteen-bit UCS Transformation Format, big-endian byte order
UTF-16LE = Sixteen-bit UCS Transformation Format, little-endian byte order
UTF-16 = Sixteen-bit UCS Transformation Format, byte order
← Google Search API and correct encoding: Previous
Discussion (1 comment)