Character encoding

Discussion in 'Java' started by raphbg@gmail.com, Jul 24, 2006.

  1. Guest

    Hi,

    I'm having some problems here with character encoding. I need to read
    a file that I have no idea which character encoding it is using. Is
    there a way to discover which encoding the file is using and convert it
    to the character encoding that I want?

    Thanks...

    Raphael
    , Jul 24, 2006
    #1
    1. Advertising

  2. cp Guest

    <> wrote in message
    news:...
    > Hi,
    >
    > I'm having some problems here with character encoding. I need to read
    > a file that I have no idea which character encoding it is using. Is
    > there a way to discover which encoding the file is using and convert it
    > to the character encoding that I want?
    >
    > Thanks...
    >
    > Raphael
    >


    Dont know if this is what you need....

    String defaultEncoding = Charset.defaultCharset().name()
    Returns the canonical name of the encodingtype used in this JVM instance.

    Another suggestion:

    String defaultEncoding = new InputStreamReader(InputStream
    in).getEncoding();
    cp, Jul 24, 2006
    #2
    1. Advertising

  3. Rogan Dawes Guest

    wrote:
    > Hi,
    >
    > I'm having some problems here with character encoding. I need to read
    > a file that I have no idea which character encoding it is using. Is
    > there a way to discover which encoding the file is using and convert it
    > to the character encoding that I want?
    >
    > Thanks...
    >
    > Raphael
    >


    You can try the Mozilla JCharDet library, which takes a statistical
    approach to identifying the character set based on presences of certain
    types of character.

    Once you have identified the charset, then you can re-read the byte
    stream using a suitable InputStreamReader, or whatever.

    Rogan
    Rogan Dawes, Jul 25, 2006
    #3
    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. Harley

    foreign character encoding

    Harley, Jul 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,998
    Harley
    Jul 26, 2003
  2. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,847
    Jon Skeet [C# MVP]
    Jun 9, 2004
  3. Replies:
    1
    Views:
    23,352
    Real Gagnon
    Oct 8, 2004
  4. raavi
    Replies:
    2
    Views:
    911
    raavi
    Mar 2, 2006
  5. Replies:
    2
    Views:
    367
Loading...

Share This Page