XmlSerializer Utf-8 encoding
Consider the code below
XmlSerializer serializer = new XmlSerializer(typeof(Invoice));
using (TextWriter writer = new StreamWriter(fileName))
{
// Serialize the object, and close the TextWriter.
serializer.Serialize(writer, invoice);
writer.Close();
}
No encoding is set on the stream writer by default. Does it default to UTF-8 if you don't set an开发者_Go百科 encoding on the stream writer?
Yes, by default StreamWriter
is created for using UTF-8 without preamble. See details here
Yes, the StreamWriter does default to UTF-8 as mentioned here
精彩评论