[jdom-interest] XMLOutputter and utf-8

Chris Curvey ccurvey at gmail.com
Thu May 19 16:07:58 PDT 2005


Hi all,

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 
http://www.fileformat.info/info/unicode/char/00c9/index.htm, the UTF-8 
encoding for E-acute should be a hex pair \xc3 and \x89. (\xc9 appears to be 
right value for UTF-16.)

Any idea what I'm doing wrong? Or am I just misinterpreting something?

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
import org.jdom.output.Format;

class JdomTest
{
public static void main (String[] argv)
{
Document doc = new Document();
Element element = new Element("foobar");
element.setText("CLOISONNÉ");
doc.addContent(element);

Format format = Format.getPrettyFormat();
format.setEncoding("UTF-8");
XMLOutputter out = new XMLOutputter(format);
System.out.println(out.outputString(doc));
} 
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050519/2d7610c3/attachment.htm


More information about the jdom-interest mailing list