且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#将UTF-8转换为ANSI

更新时间:2023-11-27 11:26:34

使用默认编码代替ASCII:

Use Default Encoding instead of ASCII:

StreamReader sr = new StreamReader(infile);  
StreamWriter sw = new StreamWriter(outfile, false, Encoding.Default);  

// invoke the ReadToEnd method
sw.WriteLine(sr.ReadToEnd());  

sw.Close();  
sr.Close();