mb_detect_encoding should be able to do the job.
http://us.php.net/manual/en/function.mb-detect-encoding.php
In it's default setup, it'll only detect ASCII, UTF-8, and a few Japanese JIS variants. It can be configured to detect more encodings, if you specify them manually. If a file is both ASCII and UTF-8, it'll return UTF-8.