开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜