[jdom-interest] Question regarding encoding

Jason Hunter jhunter at xquery.com
Thu Oct 7 11:57:41 PDT 2004

As it says in the XMLOutputter Javadoc:

<b>Warning</b>: When outputting to a Writer, make sure
the writer's encoding matches the encoding setting in the Format object.

You're not being specific about what encoding your FileWriter is using 
so the Writer takes your system default which no doubt isn't ISO-8859-1. 
  Basically you declare you're doing one thing then pass a writer that's 
doing something else.  Output using a stream and it'll be Ok because 
then JDOM can make sure the bytes get written correctly.


Sinkinson,Andrew [NCR] wrote:

>   Hi All,
>   Why are my French apostrophe being converted to questions marks ?
>   If I have the following input Xml document:
>   <?xml version="1.0" encoding="ISO-8859-1"?>
> <record>
>     <description>L’architecture de GI/TI </description>
> </record>
>   Parse the document with jdom and write it to the file system with the 
> following format
>   Format format = 
> Format.getCompactFormat().setEncoding("ISO-8859-1");                    
>   XMLOutputter out = new XMLOutputter(format);
>   FileWriter f = new FileWriter(new File(filename));
>   out.output(doc, f);
>   Here is the output:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <record><description>L?architecture de GI/TI</description></record>
>   Any help would be greatly appreciated.
>  Thanks,
>   Andrew
> ------------------------------------------------------------------------
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

More information about the jdom-interest mailing list