'GBK' is not a supported encoding name. For information on defining a custom encoding, see the docum

.net core web工程 使用“GBK” 报如下错

 

'GBK' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')

解决:

1、nuget引用 System.Text.Encoding.CodePages 包

2、在使用前 先用“System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);” 注册

    System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            byte[] server_ip = Encoding.GetEncoding("GBK").GetBytes(sendContentModel.ServerIp);

 

posted @ 2022-01-12 10:01  丁焕轩  阅读(1601)  评论(0编辑  收藏  举报