Proper use of CharsetDecoder?

H

Harald Kirsch

I have some text originating from XML which does not
contain tags anymore but character references like "@" .

I thought about writing my own java.nio.charset.CharsetDecoder only
to find that this more or less forces me to also supply a my
own java.nio.charset.Charset class ... and probably a CharsetProvider ...

Since all I want is the conversion of "&64;" and the like
to a Java char I don't see the point of defining a Charset. The
CharsetDecoder alone would suit me well passed right into
a new InputStreamReader(InputStream, CharsetDecoder).

Certainly I misunderstand the importance of the connection between
CharsetDecoder and Charset and should choose a different route.

Should I implement my own Reader having the converions built in? This seems
equally odd.

Any other ideas?

Harald.
 
R

Roedy Green

Any other ideas?
You can make it is a plain decoder class like Base64 that get called
on a byte array and produces a String.

XML can have new entities created on the fly in the DTD, which is
quite unlike all the other Charset decoders.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top