Character encoding

R

raphbg

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
 
C

cp

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();
 
R

Rogan Dawes

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
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top