Encoding agnostic way to read "German" text files

Viewed 1664

All our text-based files are encoded in UTF-8 or latin-1 (Windows). The only "special characters" we use are the German umlauts ä, ö, ü and the ß.

For different reasons (including historical, but also the old problem of "properties files cannot be UTF-8"), we cannot unify our encoding completely.

This obviously leads to errors when people read a text file in Java and use the wrong encoding.

Is there an easy, reliable way to detect whether a file is UTF-8 or latin-1 if you know that the only possible special characters are the ones indicated above.

Or do I need to read the file as byte array and search for special bytes?

1 Answers
Related