Re: Format problem?

Mike Kyle <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
It does seem that it was me being a bit of a dummy!

I should have been using a ByteArrayOutputStream to get the actual bytes.

Many thanks for the hint.




________________________________
From: Michael Kay <[email protected]>
To: Mike Kyle <[email protected]>; [email protected]
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: [email protected]  [mailto:[email protected]] On Behalf Of Mike  Kyle
Sent: 22 October 2008 11:35
To: [email protected]
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);
    
}

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.