简体   繁体   English

C#从文本文件读取希伯来语

[英]c# read hebrew from text file

I wrote a text file in the Hebrew language . 我用希伯来语写了一个文本文件。 When I present the contents of the file in C # I do not see what I wrote - I understand that it is tied to Unicode , but I do not really understand it . 当我用C#呈现文件的内容时,看不到我写的内容-我知道它与Unicode有关,但是我并不真正了解它。 Help , anyone? 帮助,有人吗?

string mymail = File.ReadAllText(@"C:\mail\mail.txt");

        MessageBox.Show(mymail);

This is the result : 结果是:

  1. Close your file and re-open it, make sure what you typed is actually persisted in your file. 关闭文件,然后重新打开,确保键入的内容确实保留在文件中。 Using the default notepad app in Windows will usually default to ASCII so the characters will not be persisted correctly on disk and so it won't be retrieved correctly either. 在Windows中使用默认的记事本应用程序通常将默认为ASCII,这样字符将无法正确保留在磁盘上,因此也将无法正确检索。
  2. You are missing your encoding, its probably defaulting to ASCII. 您缺少编码,它可能默认为ASCII。

    string mymail = File.ReadAllText(@"C:\\mail\\mail.txt", System.Text.Encoding.UTF8); MessageBox.Show(mymail);

string mymail = File.ReadAllText(@"C:\mail\mail.txt", System.Text.Encoding.GetEncoding("windows-1255")); 
MessageBox.Show(mymail);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM