Try reading it as UTF-8 and see if the UTF-8 encoding is broken or not, and if not, if there are only valid Unicode points.
But still there is no guarantee that the file is in UTF-8 or ASCII or anything else. How would you interpret a file containing one byte, the letter A ? ASCII? UTF-8? Others? Likewise, if a file starts with BOM for pure luck, but is it really not UTF-8, or not intended for UTF -8?
This article may be of interest.
source share