From 38b6fe65e36ed9442e3fc714dea1793d457f0b20 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 6 Sep 2018 20:33:40 -0400 Subject: Fix codepage handling to cover both Framework- and Core- supported code pages. --- src/WixToolset.Core/Common.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/WixToolset.Core') diff --git a/src/WixToolset.Core/Common.cs b/src/WixToolset.Core/Common.cs index ebcbd36f..2d8f9509 100644 --- a/src/WixToolset.Core/Common.cs +++ b/src/WixToolset.Core/Common.cs @@ -172,6 +172,8 @@ namespace WixToolset.Core /// The code page is invalid for summary information. public static int GetValidCodePage(string value, bool allowNoChange = false, bool onlyAnsi = false, SourceLineNumber sourceLineNumbers = null) { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + try { Encoding encoding; @@ -190,7 +192,7 @@ namespace WixToolset.Core return -1; } - encoding = CodePagesEncodingProvider.Instance.GetEncoding(codePage); + encoding = Encoding.GetEncoding(codePage); } else { @@ -208,6 +210,11 @@ namespace WixToolset.Core } } + if (encoding == null) + { + throw new WixException(ErrorMessages.IllegalCodepage(sourceLineNumbers, codePage)); + } + return encoding.CodePage; } catch (ArgumentException ex) -- cgit v1.2.3-55-g6feb