fix utf8 encoding detection