If you're just trying to tell the difference between those two encodings, then note that a lot of text encoded with Latin1 is not valid UTF-8, so simply attempting to decode it as UTF-8 will already give you a very good hint. I demonstrated this with some code (plus heuristics) in this node.
In reply to Re: Perl detect utf8, iso-8859-1 encoding
by haukex
in thread Perl detect utf8, iso-8859-1 encoding
by swiftlet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |