Environment is VS2008, .Net 3.5
The following C# code (note the specified encoding of UTF8)
XmlWriterSettings settings = new XmlWriterSettings ();
StringBuilder sb = new StringBuilder();
settings.Encoding = System.Text.Encoding.UTF8;
settings.Indent = false;
settings.NewLineChars = "\n";
settings.ConformanceLevel = System.Xml.ConformanceLevel.Document;
XmlWriter writer = XmlWriter.Create (sb, settings);
{
// Write XML data.
writer.WriteStartElement ("CCHEADER");
writer.WriteAttributeString ("ProtocolVersion", "1.0.0");
writer.WriteAttributeString ("ServerCapabilities", "0x0000000F");
writer.WriteEndElement ();
writer.Flush ();
}
Actually generates the XML (>< omitted because SO barfs on them):
?xml version="1.0" encoding="utf-16"?
CCHEADER ProtocolVersion="1.0.0" ServerCapabilities="0x0000000F" /
Why do I get the wrong encoding generated here ? What am I doing wrong ?