Force text encoding to remove the invalid characters