Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Proper use of CharsetDecoder?

Thread Tools

Proper use of CharsetDecoder?

Harald Kirsch
Posts: n/a
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?

Reply With Quote
Roedy Green
Posts: n/a
On 4 Aug 2003 10:13:10 -0700, Removed) (Harald Kirsch) wrote
or quoted :

>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.

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See for The Java Glossary.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie question on proper use of Interface Java 2 10-25-2005 01:53 PM
What's the proper way to use SocketChannel.finishConnect()? - Java 1 07-26-2005 01:03 AM
Proper use of assertions Razvan Java 5 10-08-2004 02:39 PM
Proper way to use an imported constant under 'use strict'? H. Wade Minter Perl Misc 8 04-25-2004 12:58 AM
Proper (vs. desirable) use of Graphics object Wolfgang Java 7 01-23-2004 05:42 PM