[jdom-interest] Format problem?

Mike Kyle m_t_k_nospam at yahoo.co.uk
Wed Oct 22 08:56:27 PDT 2008


Mike,

Because the formatter defaults to utf-8 if one doesn't specify it (which is what the XML document claims to be).

I'm certain that it's not the System console not showing it - the
characters in question would convert to 6 UTF-8 chars. The output spits
out 2 chars.

Cheers, Mark 



________________________________
From: Michael Kay <mike at saxonica.com>
To: Mike Kyle <m_t_k_nospam at yahoo.co.uk>; jdom-interest at jdom.org
Sent: Wednesday, 22 October, 2008 13:47:42
Subject: RE: [jdom-interest] Format problem?

 
I think it's more likely that System.out is not displaying 
the Unicode string correctly - generally my experience is that the operating 
system console is not capable of handling full Unicode, though it no doubt 
depends on the operating system and its configuration.
 
I'm not sure why you would expect to see UTF-8 (as distinct 
from other representations of Unicode).
 
Michael Kay
http://www.saxonica.com/


________________________________
 From: jdom-interest-bounces at jdom.org  [mailto:jdom-interest-bounces at jdom.org] On Behalf Of Mike  Kyle
Sent: 22 October 2008 11:35
To: jdom-interest at jdom.org
Subject: [jdom-interest] Format  problem?


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);
    
}


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20081022/901c1f1f/attachment.htm


More information about the jdom-interest mailing list