Replace invalid chars before convert utf formats