Fixes UTF-8 invalid bytes issue.