Ok, simple question.
I have a small block of code that creates some XML using XmlWriter in C# (running .NET 4.0.21006.0).
The code creates a simple XML file, but the header is preceded by what looks like 3 special characters. (When I type the file in DOS, it looks like a Union symbol followed by a double upper right boarder followed by a single upper right boarder). If I edit the file in something like Notepad or Notepad++, I do not see these characters, but they're there when I type the file from the command line.
I am using an XmlWriterSettings object with default settings. Is this the problem? The rest of the XML file appears to be perfectly fine.
The code snippet provided below shows the characters "n++" instead of the three characters; for some reason when I pasted them into the experts exchange website it did this.
How can I fix this?
// trimmed down from the actual code
// (eg- try/catch blocks removed):
string filename = "something.xml";
settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineChars = "\r\n";
writer = XmlWriter.Create(filename, settings);
writer.WriteStartDocument(true); // header
// Produces this result:
n++<?xml version="1.0" encoding="utf-8" standalone="yes"?>