[jdom-interest] SaxBuilder.build(url) and encoding

Jason Hunter jhunter at servlets.com
Wed Dec 11 21:34:25 PST 2002

When you use a URL the underlying parser determines the encoding,
typically by looking at the declaration.  If there isn't one, it assumes
UTF-8.  You can even look at the JDOM code to determine exactly what
goes on.  But this issue's with your parser or your file contents.  Most
likely you have a wrongly encoded file, since parsers tend to be pretty
good about this.


Rodrigo Alvarez wrote:
> Hi,
> I´ve a problem with encoding and using SaxBuilder.build(url) method.
> It seems that the SaxBuilder.build(url) method does not check for the
> encoding attribute in the xml head tag
> Is this correct, or is it just me?
> The following xml does give a JDOMException[Malformed UTF-8 char] when read
> by SaxBuilder.build(url) but works
> fine when read by SaxBuilder.build(File) or SaxBuilder.build(String)
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <dybox>
>    <current_date week_day="mié">
>      <day>11</day>
>      <month>12</month>
>      <year>2002</year>
>      <hour>15</hour>
>      <minute>32</minute>
>      <second>33</second>
>      <formated_date>20021211</formated_date>
>    </current_date>
> </dybox>
> My solution to the problem was read URL stream into a StringBuffer and then
> build Document object.
> I´m not satisfied with this solution so I wonder if someone else have had a
> similar problem or can confim that
> there really is a problem with JDOM.
> /Rodrigo
> Rodrigo Alvarez
> DyBOX Consulting and Development
> Hernando de Aguirre 906 Providencia.
> Santiago, Chile.
> (562) 231 7840
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

More information about the jdom-interest mailing list