Search code examples
javacoldfusioninternationalizationcoldfusion-9idn

Coldfusion with Java IDN handling international domains


I'm rewriting one of our forms so that it can handle international domains, but before I start on that i thought i would test the capabilities of handling IDNs.

My thoughts were, should someone enter a domain like: http://清华大学.cn i would store it as the punycode in my database. With this in mind I then found the Java IDN handler and wrote this bit of test code:

<cfset strUrl = "http://清华大学.cn" />
<cfoutput>
#strURL#
</cfoutput>     
<!--- Create a Java URL. --->
<cfset jUrl = CreateObject( "java", "java.net.IDN" ).toAscii(strUrl) />

<cfoutput>
#jURL#
</cfoutput>

However, upon running this I get an error:

A prohibited code point was found in the inputhttp://æ ̧...å�žå¤§å¦

This occurs on the .toAscii line. What have i missed?


Solution

  • I added <cfprocessingdirective pageencoding="utf-8"> to the top of my page which now encodes and decodes the chinese correctly using the Java IDN.

    I found this solution here in the comments section:

    http://www.bennadel.com/blog/1155-Cleaning-High-Ascii-Values-For-Web-Safeness-In-ColdFusion.htm