I have some raw data (xml) which I definitely receive containing unicode. I write them to a file using:
File.WriteAllText
This seems to remove/change unicode characters. Is there a way to prevent this?
You can specify the encoding:
File.WriteAllText(fileName, xml, Encoding.Unicode);
Try the File.WriteAllText overload which allows you to specify an encoding - just give it the same encoding of the original data.
Use the proper encoding, which is the 3rd parameter.
File.WriteAllText(file, contents, encoding);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With