fixed ill-formed utf-8 handling.