6

我正在创建一个替换文本文件中某些文本的工具。我的问题是 File ReadAllLines 将希伯来语字符变成胡言乱语(奇怪的问号)

有谁知道为什么会这样?请注意,我在游戏等方面确实遇到了希伯来语问题。在记事本中,我无法保存希伯来语文档。我可以写希伯来字母,但是当我保存它时告诉我有问题。

编辑 - 试过这个,但它只把希伯来语变成了普通的问号,而不是“特殊”的问号 -

string[] lines = File.ReadAllLines(fullFilenameDir);
byte[] htmlBytes = Encoding.Convert(Encoding.ASCII, Encoding.Unicode, Encoding.ASCII.GetBytes(String.Join("\r\n", lines)));
char[] htmlChars = new char[Encoding.Unicode.GetCharCount(htmlBytes)];
Encoding.Unicode.GetChars(htmlBytes, 0, htmlBytes.Length, htmlChars, 0);
4

1 回答 1

12

尝试使用Windows-1255代码页来获取编码器。

var myLines = File.ReadAllLines(@"C:\MyFile.txt",  Encoding.GetEncoding("Windows-1255"));
于 2013-06-11T11:01:59.417 回答