Hi all,<br>
<br>
I'm having a little trouble figuring out utf-8 encoding with
JDom. The output from this sample program is returning a single
hex value, \xc9 for an E-acute, but according to this page
<a href="http://www.fileformat.info/info/unicode/char/00c9/index.htm">http://www.fileformat.info/info/unicode/char/00c9/index.htm</a>, the UTF-8
encoding for E-acute should be a hex pair \xc3 and \x89. (\xc9
appears to be right value for UTF-16.)<br>
<br>
Any idea what I'm doing wrong? Or am I just misinterpreting something?<br>
<br>
import org.jdom.Document;<br>
import org.jdom.Element;<br>
import org.jdom.output.XMLOutputter;<br>
import org.jdom.output.Format;<br>
<br>
class JdomTest<br>
{<br>
public static void main (String[] argv)<br>
{<br>
Document doc = new Document();<br>
Element element = new Element("foobar");<br>
element.setText("CLOISONNÉ");<br>
doc.addContent(element);<br>
<br>
Format format = Format.getPrettyFormat();<br>
format.setEncoding("UTF-8");<br>
XMLOutputter out = new XMLOutputter(format);<br>
System.out.println(out.outputString(doc));<br>
} <br>
} <br>