gpt4 book ai didi

c# - XmlSerializer Utf-8编码

转载 作者:可可西里 更新时间:2023-11-01 07:44:26 25 4
gpt4 key购买 nike

考虑下面的代码

  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();
}

默认情况下流写入器上没有设置编码。如果您不在流编写器上设置编码,它会默认为 UTF-8 吗?

最佳答案

是的,默认情况下 StreamWriter 是为使用不带前导码的 UTF-8 而创建的。查看详情 here

关于c# - XmlSerializer Utf-8编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1769512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com