I have raw data (xml) that I definitely get containing unicode. I write them to a file using:
File.WriteAllText
This seems to remove / change Unicode characters. Is there any way to prevent this?
Thanks.
Christian
Try File.WriteAllText overload, which allows you to specify the encoding - just give it the same encoding of the source data.
You can specify the encoding:
File.WriteAllText(fileName, xml, Encoding.Unicode);
you can specify the Encoding as parameter for the WriteAllText function, see the available overloads :)
Use the correct encoding, which is the third parameter.
File.WriteAllText(file, contents, encoding);