Thanks. I do not know much about the different encodings and how the FileWriter and FileOutputStream works. This solved my problem.
Robert Lowe wrote:
>
> Hmm, JAXB creates documents using the UTF-8 character encoding by
> default, so it should be able to handle any Unicode character without
> problems. I've personally used JAXB 1.0 to create JAXB documents
> containing Chinese and Japanese characters as well as accented Roman
> characters, so I believe JAXB is solid in this regard.
>
> I suspect it's a problem with the way you're using JAXB rather than a
> problem with JAXB itself--for example, marshalling to a Writer, and then
> encoding this using an encoding that doesn't match the encoding used in
> marshalling. For example, the code below will almost certainly produce
> incorrect output:
>
> FileWriter writer = new FileWriter("myfile.xml");
> marshaller.marshal(myJaxbObject, writer);
>
> The problem here is that, by default, JAXB will include an XML
> declaration something like:
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> However, the FileWriter uses the platform-specific default character
> encoding, which almost certainly *won't* be UTF-8, resulting in a
> mismatch between the declared encoding and the actual encoding. The safe
> way to do this would be:
>
> FileOutputStream os = new FileOutputStream("myfile.xml");
> marshaller.marshal(myJaxbObject, os);
>
> If you still think there's a problem with JAXB, I'd suggest you create a
> simple test case, and then submit this to the mailing list together with
> sample output.
>