How to read text files with ANSI encoding and non-English letters?

前端 未结 4 1009
走了就别回头了
走了就别回头了 2020-12-02 20:21

I have a file that contains non-English chars and was saved in ANSI encoding using a non-English codepage. How can I read this file in C# and see the file content correctly?

4条回答
  •  天涯浪人
    2020-12-02 20:37

     var text = File.ReadAllText(file, Encoding.GetEncoding(codePage));
    

    List of codepages : http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

提交回复
热议问题