Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] Document encoding

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Mike Fitzgerald" <mike AT wyeast.net>
  • To: Örjan Reinholdsen <orjan.reinholdsen AT home.se>, "XOM" <xom-interest AT lists.ibiblio.org>
  • Subject: RE: [XOM-interest] Document encoding
  • Date: Wed, 5 Feb 2003 15:18:10 -0800

Hello Örjan,

I think XOM generally avoids things that could be done with idiomatic Java.

Checking for UTF-8/Writing UTF-16

You probably already know this, but...couldn't you just use something like
DataInputStream.readUTF()/UTFDataFormatException, to easily check for UTF-8?
Or is there something easier? To check for UTF-16, you just need to check
for a BOM, which of course is the big road sign that says "I'm not UTF-8,
I'm UTF-16." And couldn't you write with something like
nu.xom.Serializer(out, "UTF-16");?

Why Serializer Would Work

Since standard Java implementations aren't required to be able to write
UCS-2, only UTF-16, UTF-16BE, and UTF-16LE, UTF-16 will work in place of
UCS-2 because, fortunately, it maps char to char from 0x0000-0xFFFF
(omitting 0xD800-0xDFFF). UTF-16 uses only one 16-bit integer (like UCS-2, I
think) to represent characters up to U+10000, then with two 16-bit integers
beyond, so if you are using characters less than U+10000 -- which you are
because UCS-2 only goes to 0xFFFF -- you should be fine.

I hope this helps. I'm just throwing out some ideas, throw some back if you
like.

Mike


> -----Original Message-----
> From: xom-interest-admin AT lists.ibiblio.org
> [mailto:xom-interest-admin AT lists.ibiblio.org]On Behalf Of Örjan
> Reinholdsen
> Sent: Wednesday, February 05, 2003 1:23 PM
> To: xom-interest AT lists.ibiblio.org
> Subject: [XOM-interest] Document encoding
>
>
> Hi everyone,
>
> I'v been using XOM for some time now and found it very simple to learn
> but still very powerfull. But now I'v hit the wall and need some help.
>
> What I want to know is the character encoding of the source XML
> document. I need this information to perform transcoding correctly, e.g.
> from UTF-8 (XML default) to UCS-2.
>
> I'v looked around in the API docs and tried variouse things, but whitout
> luck. Am I missing something or is it impossible?
>
> Warm regards
> /Örjan
>
>
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest
>





Archive powered by MHonArc 2.6.24.

Top of Page