|Reading files encoded in ANSI and UTF-8 [message #677093]
||Tue, 07 June 2011 14:52
Registered: May 2011
I posed a question regarding running the same program inside Eclipse and outside
Eclipse with different behavior. I have a program that reads a text file with
When I run the program inside Eclipse, if the file is UTF-8 encoding, it is read
correctly and if the file is ANSI encoded, it does not read it correctly.
But now if I export the same program to a runnable jar file and run it outside
of Eclipse. This time, if the file is ANSI encoded, it is read correctly and
if it is UTF-8 encoded, it is not.
Of course, it the file just contains normal alphabets and numbers, the program
will read it correctly inside or outside Eclipse without regard to its encoding.
Which means my program reads ANSI files and UTF-8 files inside Eclipse correctly
if the ANSI file does not contain Chinese characters.
Now I need to encode my file with UTF-8 so my program will read it correctly inside
Eclipse. Once I decided that my program is OK and export to an external jar file,
I need to use something like Notepad++ to encode my file to ANSI so my program
can read it correctly outside Eclipse. That seems to be a lot of hassle.
Does anyone know a better way?
Thanks a lot in advance.
Powered by FUDForum
. Page generated in 0.02101 seconds