fixing UTF-8 processing bugs