fix UTF-8 detection bug