Detect codepage in text files - Help!
807591Mar 13 2008 — edited Mar 17 2008Hi, 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