The BOM is an aBOMination. If you simply assume that everything is UTF-8 until proven otherwise, you can get pretty far - the legacy code pages produce text that&#x27;s not usually valid UTF-8 unless they stick to ASCII.