[jdom-interest] Element.getText and encoding
de Grijs, Rudolf
Rudolf.de_Grijs at softwareag.com
Mon Mar 5 04:34:54 PST 2001
Thx Ken Rune,
Rudolf
-----Original Message-----
From: Ken Rune Helland [mailto:kenh at csc.no]
Sent: maandag 5 maart 2001 13:14
To: de Grijs, Rudolf
Subject: Re: [jdom-interest] Element.getText and encoding
At 11:56 AM 3/5/2001 +0100, you wrote:
>Could someone help me out?
>
>If I would like to get the text of an element, I can use the getText()
>method to get to the text node of that element. Is it possible to influence
>the encoding setting before I use getText().
>
>I do know that I can use the XMLOutputter class (which has a method
>setEncoding()), but I would find it useful to have similar functionality
>with the method getText().
>
>
>regards,
>Rudolf de Grijs
Hello.
The text (String objects) inside java is always unicode,
the parser will translate to unicode char's from the encoding
set in the xml document with the encoding attribute in the
xml declaration. The XMLOutputter translates from unicode to the
output encoding set with XMLOutputter.setEncoding().
You can turn a java String ( with 16 bit characters )
into a (8 bit) byte array with a spesific encoding using
String.getBytes(String encoding)
Best Regards
KenR
More information about the jdom-interest
mailing list