编码从ANSI更改为UTF8

问题描述:

我需要用我的代码打开一个txt文件,但是该文件采用ANSI(windows 1255)编码,并将其转换为UTF-8.我该怎么做?

I need to open a txt file in my code, but this file is in ANSI (windows 1255) encoding, and convert it to UTF-8. How can I do that?

让我们快速完成:用
阅读
Let''s do it quickly: read it with
System.IO.StreamReader reader =
    new System.IO.StreamReader(fileName, System.Text.ASCIIEncoding.ASCII, false);

使用

System.IO.StreamWriter writer =
    new System.IO.StreamWriter(fileName, false, System.Text.UTF8Encoding.UTF8);



—SA



—SA