This method is writing out an XML file (work specific). I have everything writing out exactly was I want it except that that I set it to write the file with UTF-8 (no BOM) encoding.
The XML declaration says UTF-8, but when I open the file in Notepad++, it shows to be encoded in ANSI.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = new UTF8Encoding(false);
settings.NewLineOnAttributes = true;
using (var xmlWriter = XmlWriter.Create(@"c:\temp\myUIPB.xml", settings))
{
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("UIScript");
// Write Event Nodes
foreach (var eventNode in listBoxOutput.Items)
{
lbEvent myNode = (lbEvent)eventNode;
XmlNode xn = myNode.workflowEvent;
xn.WriteTo(xmlWriter);
}
xmlWriter.WriteFullEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
}
I would expect that if I set it to output in UTF-8, that the file that writes out is indeed encoded in UTF-8 instead of ANSI encoded.
Thoughts? Help?