I recommend using a Java library such as Junidecode. https://github.com/gcardone/junidecode
It converts the strings UTF8 and UTF16 to ASCII7. Examples:
- mike cafe = mike cafe
- ℡ = TEL
- Be 亰 = Bei Jing
- Mr. ま さ ゆ き た け だ = Mr. Masayuki Takeda
- ⠏⠗⠑⠍⠊⠑⠗ = prime
- ไทย อาณาจักร ไทย = raach'aanaacchakraithy
- Ελληνικά = Ellenica
- Moscow = Moscow
- Հայաստան = Ayastan
- ℰ𝒳𝒜ℳ𝓟ℒℰ = EXAMPLE
I shared a full demo based on ColdFusion (which requires a Junidecode JAR file): https://gamesover2600.tumblr.com/post/182608667654/coldfusion-unicode-junidecode-demo
Here is the function code:
<cfscript> function JUnidecode(inputString){ var JUnidecodeLib = ""; var response = ""; var temp = {}; temp.encoder = createObject("java", "java.nio.charset.Charset").forName("utf-8").newEncoder(); temp.isUTF = temp.encoder.canEncode(arguments.inputString); if (temp.isUTF){ temp.normalizer = createObject( "java", "java.text.Normalizer" ); temp.normalizerForm = createObject( "java", "java.text.Normalizer$Form" ); arguments.inputString = temp.normalizer.normalize( javaCast( "string", arguments.inputString ), temp.normalizerForm.NFKC ); } try { JUnidecodeLib = createObject("java", "net.gcardone.junidecode.Junidecode"); response = JUnidecodeLib.unidecode( javacast("string", arguments.inputString) ); } catch (any e) { response = "ERROR: JUnidecode is not installed"; } return trim(Response.replaceAll("\[\?\]", "")); } function isDiff(compareArr, val, pos){ return (pos GT arrayLen(comparearr) OR comparearr[pos] neq val); } </cfscript>
source share