Hello Graham,

This is neither a Xerces bug or a bug in Java. When you pass the serializer a Writer rather than an OutputStream it will write characters not bytes. If the Writer is writing to an OutputStream, it is responsible for encoding the characters and will do whatever it does regardless of what encoding you specified on the serializer. Note that FileWriter [1] assumes the default character encoding which appearently is UTF-8 on one machine and ISO-8859-1 on another.

[1] http://java.sun.com/j2se/1.5.0/docs/api/java/io/FileWriter.html

On Tue, 26 Apr 2005, Graham Leggett wrote:

The error seems to be with Xerces writing out an XML file. Under Linux, Xerces writes UTF-8 data correctly. Under Windows however, Xerces outputs ISO-8859-1 instead, even though it has been expressly told to output UTF-8. The code to output the XML is as follows:

 Writer writer = new FileWriter(this.workboxFile);
 OutputFormat outputFormat = new OutputFormat("xml", "UTF-8", true);
 XMLSerializer serial = new XMLSerializer(writer, outputFormat);
 serial.asDOMSerializer();
 serial.serialize(this.workboxDocument);
 writer.close();

I've either run into a Xerces bug, or a Java bug, or I have done something stupid. Has anybody on this list run into anything like this before?

Regards,
Graham
--


--------------------------- Michael Glavassevich E-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to