fix_encoding in text_mode