首页 > 解决方案 > Ubuntu 16.04 下 C# 单声道项目的 windows-1251 编码

问题描述

我艰难的生活迫使我在 Ubuntu 16.04 下的 C# 上使用“windows-1251”编码。我使用“单声道”来运行 C#。

两个命令

 Encoding.GetEncoding(1251)
 Encoding.GetEncoding("windows-1251")

给这个例外

System.NotSupportedException: Encoding 1251 data could not be found. Make sure you have correct international codeset assembly installed and enabled.
  at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0023f] in <65984520577646ec9044386ec4a7b3dd>:0

根据这个答案,我需要使用

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

但我的 c# 找不到“RegisterProvider”。据我了解,我需要手动包含“System.Text.Encoding.CodePages”。评论中描述了一些步骤,但我不明白在哪里可以下载它以及如何链接它。

有人可以建议我如何包含它(如果它解决了问题)或告诉我一般该怎么做。

标签: c#ubuntuencodingwindows-1251

解决方案


推荐阅读