From: William W. <wo...@al...> - 2010-02-01 08:22:08
|
I'm using XMLVM to cross-compile some math routines to be embedded into an iPhone/iPad application. One of the problems I ran across was that when a unicode character was added as part of a Java string ("\uxxxx"), it was being emitted in the Objective C code as "\xxxxx", with the characters as octal characters. The following change causes characters to be output as unicode characters instead: Around lines 812-822 of DEXmlvmOutputProcess.java (org.xmlvm.proc.out), replace: } else if (constant instanceof CstString) { CstString cstString = (CstString) constant; String valueOriginal = cstString.getString().getString(); String value = ""; // Convert special characters in string to octal notation for (int i = 0; i < valueOriginal.length(); i++) { char ch = valueOriginal.charAt(i); value += (ch < ' ' || ch > 'z') ? String.format("\\%03o", new Integer(ch)) : ch; } dexInstruction.setAttribute("value", value); with } else if (constant instanceof CstString) { CstString cstString = (CstString) constant; String valueOriginal = cstString.getString().getString(); String value = ""; // Convert special characters in string to octal notation for (int i = 0; i < valueOriginal.length(); i++) { char ch = valueOriginal.charAt(i); value += (ch < ' ' || ch > 'z') ? String.format("\\u%04x", new Integer(ch)) // ^^^^^^^^^^ Change here. : ch; } dexInstruction.setAttribute("value", value); Of course this is sub-optimal, given that this only works if targeting Objective C platforms, where "\uxxxx" is an accepted unicode character escape. But I'm putting it out there for what it's worth. - Bill Woody |