我正在尝试使用XMLWriter构建XML,但是它包含编码UTF-16。我尝试了将其修改为UTF-8的解决方案。但是没有任何作用
var settings = new XmlWriterSettings
{
Encoding = new UTF8Encoding(true),
Indent = false,
OmitXmlDeclaration = false,
NewLineHandling = NewLineHandling.None
};
答案 0 :(得分:0)
尝试覆盖UTF8String Writer
private class UTF8StringWriter : StringWriter
{
public override Encoding Encoding
{
get
{
return Encoding.UTF8;
}
}
}