Recognize UTF-8 BOM and some other cases