Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Detect codepage in text files - Help!

807591Mar 13 2008 — edited Mar 17 2008
Hi, I'm a newbie about this kind of problem.
I wrote a class that reads an input .txt, manages the content to another format and then writes another .txt file.
Since in the input file there are some characters with accents, they cause problems during the corversion, and the output file contains some "strange" chars.
I expected that I was reading a file saved with UTF-8 codepage. I tried to save with ANSI codepage, and my class works good.
I can't understand why the class works in this way, since UTF-8 is the "native" codepage in Java. Anyway, I'm searching for a way to test the input file codepage before reading it, or to convert into a manageable file... Maybe with examples of code. I've searched into other threads about this problem, with no results.
I work on Windows XP platform, using JDK 1.6 update 5.
Thanks in advance, Maurizio
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2008
Added on Mar 13 2008
8 comments
1,447 views