'GB2312' is not a supported encoding name. For information on defining a custom encoding 电脑版发表于:2020/9/2 17:02 在.net core3.1使用GB2312时抛出以下异常 System.ArgumentException:“'gb2312' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. tn3#解决方法 在NuGet 添加“System.Text.Encoding.CodePages” 在代码中还需要添加 ``` Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ``` 核心代码如下 ``` static void Main(string[] args) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); byte[] bytes = Encoding.GetEncoding("gb2312").GetBytes("哈哈哈www.tnblog.net"); string s = Encoding.GetEncoding("GB2312").GetString(bytes); Console.WriteLine("Hello tnblog"); } ```