@marcusxms
Any byte sequence is valid latin1, so there's no reliable way to detect it. You can only guess, maybe with the help of dictionaries or at least tables of characters that commonly appear within words.
Depending on your usecase it may be enough to test for ASCII and UTF-8 first, and assume latin1 if both fail.