In C # programming will inevitably encounter when the occasion requires transcoding.
Can be used System.Text.Encoding resolved Framwork, but it will be found to the core, although there are this thing, but several key Chinese encoding (such as GB2312) find none.
even if you are Chinese or Chinese Windows system linux system.
Test code:
static void Main(string[] args)
{
var gb2312=Encoding.GetEncoding("GB2312");
gb2312=gb2312;//此处打断点
Console.WriteLine("Hello World!");
}
Solution:
Nuget install this package: System.Text.Encoding.CodePages
dotnet add package System.Text.Encoding.CodePages
This package provides Chinese code page, after the installation, the code registered at the very beginning (during the entire program runs only need to register once, takes effect globally):
static void Main(string[] args)
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
var gb2312=Encoding.GetEncoding("GB2312");
gb2312=gb2312;//此处打断点
Console.WriteLine("Hello World!");
}
result: