A command-line tool to detect which charset/encoding a file is in:
It is based on open-source code from Mozilla. It works amazingly well even on files in hard-to-distinguish charsets. Being good not only at distinguishing UTF-8 from the 8-bit encodings, but also at distinguishing the different windows-125x and 8859-x encodings from each other.
Here is the ChangeLog with some details on how version-2.00 performs on a variety of tests.