Java Mailing List Archive

http://www.junlu.com/

Home » JDOM Projects »

[jdom-interest] Format problem?

Mike Kyle

2008-10-22

Replies: Find Java Web Hosting

Author LoginPost Reply
The following code does NOT produce the UTF-8 that I had expected. As far as I can tell the Text element only seems to work with ASCII text. I would have expected it to work with non-ASCII text. Or am I doing something dumb?

    private void jdomTest() throws IOException
    {
        Element element = new Element("doc");
        element.addContent(new Text("\u4E2D\u6587"));
        Document document = new Document(element);

        StringWriter out = new StringWriter();
        Format f = Format.getPrettyFormat();
        new XMLOutputter(f).output(document, out);
        System.out.println("XML: "+out);
    }


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.