Remove BOM marker from the middle of !traversexml (#3844)
authorLee Culver <leculver@microsoft.com>
Wed, 19 Apr 2023 18:55:53 +0000 (11:55 -0700)
committerGitHub <noreply@github.com>
Wed, 19 Apr 2023 18:55:53 +0000 (18:55 +0000)
src/Microsoft.Diagnostics.ExtensionCommands/TraverseHeapCommand.cs

index 64647201a0aa326c8d1a860d06803d2221cb73a5..40d28205028b60a5792ec6eb41e19589517e15d7 100644 (file)
@@ -36,7 +36,7 @@ namespace Microsoft.Diagnostics.ExtensionCommands
 
             // create file early in case it throws
             using StreamWriter output = File.CreateText(Filename);
-            using (XmlWriter xml = Xml ? XmlWriter.Create(output, new XmlWriterSettings() { Indent = true, OmitXmlDeclaration = true }) : null)
+            using (XmlWriter xml = Xml ? XmlWriter.Create(output, new XmlWriterSettings() { Encoding = new UTF8Encoding(true), Indent = true, OmitXmlDeclaration = true }) : null)
             {
                 using StreamWriter text = Xml ? null : output;
 
@@ -81,6 +81,7 @@ namespace Microsoft.Diagnostics.ExtensionCommands
             using StreamWriter text = Xml ? null : new StreamWriter(rootObjectStream, Encoding.Default, 4096, leaveOpen: true);
             using XmlWriter xml = Xml ? XmlWriter.Create(rootObjectStream, new XmlWriterSettings()
             {
+                Encoding = new UTF8Encoding(false),
                 CloseOutput = false,
                 Indent = true,
                 OmitXmlDeclaration = true,