From d50faf254beaa7f466061d933b6196e6e9228800 Mon Sep 17 00:00:00 2001 From: Xavier Hahn Date: Thu, 1 Oct 2020 22:42:17 +0200 Subject: [PATCH 1/3] Change default encoding for GetEncoding The System.Management.Automation.Utils.GetEncoding method should return UTF8 without BOM as a default but was returning ASCII. This is fixed by returning an instance of the Utf8Encoding with the BOM set to false. --- src/System.Management.Automation/engine/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 12f170937e0..4e551592084 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1458,7 +1458,7 @@ internal static Encoding GetEncoding(string path) return Encoding.Unicode; } - return Encoding.ASCII; + return new UTF8Encoding(false); } // BigEndianUTF32 encoding is possible, but requires creation From f098c4ff1a8792bea128392ad80efaa584020b7f Mon Sep 17 00:00:00 2001 From: Xavier Hahn Date: Fri, 2 Oct 2020 07:47:16 +0200 Subject: [PATCH 2/3] Update src/System.Management.Automation/engine/Utils.cs Add the label for the boolean argument Co-authored-by: Ilya --- src/System.Management.Automation/engine/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 4e551592084..440bdd0e0b8 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1458,7 +1458,7 @@ internal static Encoding GetEncoding(string path) return Encoding.Unicode; } - return new UTF8Encoding(false); + return new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); } // BigEndianUTF32 encoding is possible, but requires creation From ba24840dfd8f3b40b92c60a668f512cfa04303c1 Mon Sep 17 00:00:00 2001 From: Xavier Hahn Date: Thu, 8 Oct 2020 22:15:52 +0200 Subject: [PATCH 3/3] use the static readonly instance --- src/System.Management.Automation/engine/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 440bdd0e0b8..0396f11c76a 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1458,7 +1458,7 @@ internal static Encoding GetEncoding(string path) return Encoding.Unicode; } - return new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); + return utf8NoBom; } // BigEndianUTF32 encoding is possible, but requires creation