日期:2014-05-17  浏览次数:21008 次

C#使用StreamWriter生成UTF-8无BOM编码格式

使用UTF-8格式产生的文件,用二进制查看会多出“\xef\xbb\xbf”几个字节

使用UTF-8无BOM格式:

UTF8Encodingutf8 = new UTF8Encoding(false);

StreamWriter  sw = new StreamWriter (strPath,false,utf8);

sw.WriteLine(strHtml);