1. 引入了System.Text.Encoding.CodePages.dll

2. 在启动的时候,注册EncodingProvider,执行代码如下:

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

这样,就可以在程序中使用GB3212编码了。

相关内容:

Platform Notes: .NET Core

By default, .NET Core does not make available any code page encodings other than code page 28591 and the Unicode encodings, such as UTF-8 and UTF-16. However, you can add the code page encodings found in standard Windows apps that target the .NET Framework to your app. For complete information, see theCodePagesEncodingProvider topic.

注解:默认情况下,.NET CORE只支持28951、UTF-8、UTF-16,其他的编码格式均不支持。但是,我们可以在.NET Framework开发的标准Windows应用程序中使用。完整的信息,请查看CodePagesEncodingProviderCodePagesEncodingProvider的url就是如下2中的地址。

2. https://msdn.microsoft.com/en-us/library/mt643901(v=vs.110).aspx

相关内容:

The CodePagesEncodingProvider class ext