diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 21be97d567e..1495c21707d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -1682,6 +1682,8 @@ internal long SetRequestContent(HttpRequestMessage request, byte[] content) /// internal long SetRequestContent(HttpRequestMessage request, string content) { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + if (request == null) throw new ArgumentNullException(nameof(request)); @@ -1731,6 +1733,8 @@ internal long SetRequestContent(HttpRequestMessage request, string content) internal long SetRequestContent(HttpRequestMessage request, XmlNode xmlNode) { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + if (request == null) throw new ArgumentNullException(nameof(request)); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs index 9314cfd1a5d..ceaf36a9a18 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs @@ -414,6 +414,8 @@ private static string StreamToString(Stream stream, Encoding encoding) internal static string DecodeStream(Stream stream, string characterSet, out Encoding encoding) { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + try { encoding = Encoding.GetEncoding(characterSet); @@ -428,6 +430,8 @@ internal static string DecodeStream(Stream stream, string characterSet, out Enco internal static bool TryGetEncoding(string characterSet, out Encoding encoding) { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + bool result = false; try {