simple non-utf8 detection (enough to detect latin-1) + BOM detection, fix #797