fixed invalid utf-8 byte issue by replacing undefined characters