Fixing encoding issues the fast and safe way (not requiring mbstring now)