[jdom-interest] Character encoding from UTF-8 to ISO-8859-1

Alex Rosen arosen at silverstream.com
Tue Feb 5 08:50:10 PST 2002


Trying to figure out character encoding issues is very tricky. There are a
number of places in the process where the problem could be. Even worse, it's
often confusing to look at a file and determine if it's correct or not,
because the character set you're using to view it is a factor.

If you have a JDOM document, then XMLOutputter will correctly output it in
the character encoding that you specify. Call setEncoding() on it, and then
call the version of output() that takes an OutputStream (not a Writer). (Or
use the version that takes a Writer, but make sure you set the Writer's
encoding properly.) This should work fine.

The "funny characters" you're seeing could be from several reasons: it's not
being stored in the database with the wrong encoding; it's being retrieved
with the wrong encoding; or most likely, you're viewing it using the wrong
encoding. The funny characters may just be the ISO-8859-1 characters, if
your system uses a different default character set.

Alex

> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of dumdum 420
> Sent: Sunday, February 03, 2002 4:29 PM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] Character encoding from UTF-8 to ISO-8859-1
>
>
> I have a xml feed with encoding set to UTF-8. This contains
> certain European
> characters. I have to parse this XML and insert it into
> Oracle Database
> which supports ISO-8859-1.
>
> Once I accomplish the output of the insert make the
> characters some of them
> look very very funny.
>
> Is they a way in Java or a workaround how I can convert from UTF-8 to
> ISO-8859-1 in a exact fashion.
>
> Take care.
>
> Bhanu Pabreja.
>
> Here is a simple line try converting it to ISO-8859-1 from
> UTF-8 and you can
> figure out how it is done.
>
> <testForConversionToISO88591>
> The purpose of this abstract is to test passing foreign
> characters from the
> Notes system, through UTF-8 xml, into Oracle, and then
> ultimately back out
> into UTF-8 XML that sits on the file system. This abstract
> contains the
> following foreign characters:
> [ Euro symbol: €  ] [ Full Quotes:  “Competing on the Edge”
> ] [ Normal
> Quotes: “Competing on the Edge” ] [ m-dash:  –  ] [
> characters: ØÅ ] [ “e”
> accent aigu: é ] [ “e” with circumflex: ê ] [ “a” accent
> grave: à ] [ “u”
> with umlaut: ü ] [ “o” with umlaut: ö ] [ “a” with umlaut: ä ]
> </testForConversionToISO88591>
>
>
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com




More information about the jdom-interest mailing list