Barnabas Davoti wrote:
So - what should we use for encoding? StringWriter or another binary OutputStream?Of course I was toooo quick.
According to the JavaDoc:
"Warning: using your own Writer may cause the writer's preferred character encoding to be ignored. If you use encodings other than UTF8, we recommend using the method that takes an OutputStream instead."
...what I misunderstood first, thought "Writer" refers to the XMLWriter class in this case, what confused me and just skipped the note.
However the second sentence of the warning is not quite correct - the default encoding is not utf8.
BR.
Barna
Barnabas Davoti wrote:
Yes it works this way, but only if you pass here an OutputStream. If you pass a Writer object instead (using an other constructor) it'll not function:
OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8"); FileWriter fileWriter = new FileWriter(outFile); XMLWriter xmlWriter = new XMLWriter(fileWriter, format); xmlWriter.write(doc);
I think it's a correct way of using the API, but I still get ANSI encoding. As I'm aware it's not possible to change the Writer's encoding as far as it's already created. ...and so the API doesn't do it. The encoding was set for the OutputFormat is simply not used in this case.
So it's an inconsistent functioning of the API or we can say it's a bug.
Also - Document.asXML() seems to always return the data in UTF-8 and not paying attention to the encoding - bad.
------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user