ISO 88591 file encoding charset in Linux

Hello Experts, please help to provide any insight as I am facing issue migrating java application from hpux to redhat. The java program is using InputStreamReader to read a file without specifying any charset parameter.

However, in new Linux Redhat 5.6 environent, when reading a file that contains Latin char, I have to either
1) set my locale to ISO 88591 or
2) specifying InputStreamReader to read as ISO 88591 or
3) convert the file using iconv from ISO 88591 to UTF-8
to read the file contents correctly.

The problem here is, I need to read files from different encoding, thus option 1 & 2 is out. While for option 3, the file is some kind of binary file, I could not use file command to determine the file encoding before issue iconv. :frowning:

To my knowledge Java InputStreamReader will use system's locale setting if no charset is specified.

New server: Red Hat Enterprise Linux Server release 5.6 (Tikanga)
(gcc version 4.1.2 20080704 (Red Hat 4.1.2-50))
locale:
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Old server: HP-UX czhs0850 B.11.11
locale:
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_MESSAGES="C"
LC_ALL=

I am not sure why previous hpux does not have this problem, it seems like the same file is interpreted as UTF8 while it reach hpux server but treated as ISO 88591 in Redhat server. I have tried to change Redhat locale to "C" as well but it's not working either.

Could it be I need to specify the encoding to UTF8 while mounting the file system? so that all incoming files write to the server will be treated as UTF8?

Why not make an input stream reader for each type as you find it? It's just an object, dereference it and it destroys, new another. First, you need to run unix 'file' on it or find an equivalent JAVA facility: Is there a java library equivalent to file command in unix - Stack Overflow