PhoenixmlDb.Core

Utf8StringWriter

A that reports its encoding as UTF-8.

#Utf8StringWriter

Namespace: PhoenixmlDb.Xdm.Parsing.XmlSerializer

A

that reports its encoding as UTF-8.

When XmlWriter writes to a StringWriter (or StringBuilder), it reads the declared encoding from TextWriter.Encoding — which is always UTF-16 for .NET strings, regardless of the XmlWriterSettings.Encoding property. Overriding Utf8StringWriter.Encoding here makes the XML declaration say encoding="utf-8", which is the correct declared encoding for content consumed as a .NET string and later saved / transmitted as UTF-8 bytes.