Fix encoding issues with text data