fix potential utf8 errors