Proper use of CharsetDecoder?

Discussion in 'Java' started by Harald Kirsch, Aug 4, 2003.

  1. 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.
     
    Harald Kirsch, Aug 4, 2003
    #1
    1. Advertising

  2. Harald Kirsch

    Roedy Green Guest

    On 4 Aug 2003 10:13:10 -0700, (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 http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 5, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Niko
    Replies:
    1
    Views:
    610
    Steve Horsley
    Dec 2, 2003
  2. Wolfgang
    Replies:
    7
    Views:
    459
    Dale King
    Jan 23, 2004
  3. Razvan

    Proper use of assertions

    Razvan, Oct 7, 2004, in forum: Java
    Replies:
    5
    Views:
    507
  4. -

    CharsetDecoder issue

    -, Jul 6, 2005, in forum: Java
    Replies:
    1
    Views:
    448
    Chris Head
    Jul 6, 2005
  5. H. Wade Minter
    Replies:
    8
    Views:
    308
    Robin
    Apr 25, 2004
Loading...

Share This Page