Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Character encoding

Reply
Thread Tools

Character encoding

 
 
raphbg@gmail.com
Guest
Posts: n/a
 
      07-24-2006
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

 
Reply With Quote
 
 
 
 
cp
Guest
Posts: n/a
 
      07-24-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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();


 
Reply With Quote
 
 
 
 
Rogan Dawes
Guest
Posts: n/a
 
      07-25-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

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
Reading Text File Encoding and converting to Perls internal UTF-8 encoding sln@netherlands.com Perl Misc 2 04-17-2009 11:22 PM
character encoding +missing character sequence raavi Java 2 03-02-2006 05:01 AM
Character encoding H van de Ven Firefox 4 12-30-2004 10:32 PM
changing JVM encoding; setting -Dfile.encoding doesn't work pasmol@plusnet.pl Java 1 10-08-2004 09:50 PM
Encoding.Default and Encoding.UTF8 Hardy Wang ASP .Net 5 06-09-2004 04:04 PM



Advertisments