Does it make more sense (and would it work) to instead just call
Document.asXML().getBytes("utf-8")? Logically that should work.

Thanks - dave


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Thielen
Sent: Monday, August 09, 2004 9:26 AM
To: 'Maarten Coene'
Cc: [EMAIL PROTECTED]
Subject: RE: [dom4j-user] Asking again: setText() doesn't convert to utf-8

Hello;

Just to confirm, if I do this then the Document.asXML() will return a string
with the characters in utf-8? (Actually getting utf-8 as a string is a weird
concept - it's more like you should query for something like byte []
Document.asXmlAsByteArray().)

Anyways, will Document.asXML().getBytes() then give me a correct utf-8 byte
array? I ask because it's weird that you set a maximum allowed character as
utf-8 is pretty straightforward as to what is converted.

Also, I can't find a XMLWriter.setMaximumAllowedCharacter() and in the dom4j
javadoc index I can't find a setMaximumAllowedCharacter() for any class.

??? - thanks - dave


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Maarten Coene
Sent: Monday, August 09, 2004 4:34 AM
To: David Thielen
Cc: [EMAIL PROTECTED]
Subject: Re: [dom4j-user] Asking again: setText() doesn't convert to utf-8

Hi David,

if you want to convert these characters greater than 0x7f, you'll have 
to create your xml like this:

org.dom4j.Document document = [...]
org.dom4j.io.XMLWriter writer = new org.dom4j.io.XMLWriter();
java.io.StringWriter strWriter = new java.io.StringWriter();
writer.setWriter(strWriter);
writer.setMaximumAllowedCharacter(127);
writer.write(document);
String xml = strWriter.toString();

regards,
Maarten


David Thielen wrote:

> Hi;
>
> I am creating a DOM using Document and Element.setText(). The created 
> xml from Document.asXML() is set to encoding="utf-8". However, it 
> appears that while it converts items like < to &lt;, it doesn't 
> convert chars that are greater than 0x7f to their utf-8 value. Is 
> there something special I have to do?
>
> Thanks - dave
>





-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user




-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to