title author date CreateTime categories
dotnet core 使用 GBK 编码
lindexi
2019-11-29 08:32:11 +0800
2019-8-29 9:38:8 +0800
dotnet

本文告诉大家如何在 .NET Core 中使用 GBK 编码

默认的 .NET Core 框架不包含 GBK 编码,不包含除了代码页为 28591 和 Unicode(utf-8,utf-16) 之外的其他编码,需要安装 System.Text.Encoding.CodePages 才能使用

先通过 NuGet 安装 System.Text.Encoding.CodePages 库

然后在使用之前调用下面方法,注意下面的方法只需要在程序集内调用一次

//使用CodePagesEncodingProvider去注册扩展编码。
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

这个代码是做注册,可以在启动的时候调用

获取 GBK 可以使用下面方法

//注册GBK编码
Encoding encodingGbk = Encoding.GetEncoding("GBK");

C# 判断文件编码

dotnet core 使用 GBK 编码

VisualStudio 编码规范工具 2.6 修改当前文件编码

win10 uwp 读取文本GBK错误

2019-11-29-dotnet-core-使用-GBK-编码

相关文章:

  • 2021-08-20
  • 2021-08-09
  • 2021-08-27
  • 2021-06-24
  • 2021-06-13
  • 2021-10-02
  • 2021-11-14
猜你喜欢
  • 2021-09-14
  • 2021-09-13
  • 2022-02-22
  • 2021-10-25
  • 2021-07-14
  • 2021-07-10
  • 2022-12-23
相关资源
相似解决方案