【发布时间】:2026-01-22 11:10:01
【问题描述】:
使用下面的代码,我以 ANSI 编码结束了它。有什么想法吗?
Encoding utf8WithoutBom = new UTF8Encoding(false);
using (FileStream fs = new FileStream("c:\\text.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{
StreamWriter sw = new StreamWriter(fs, utf8WithoutBom);
sw.Write("sfsdfsdfsdf");
sw.Flush();
sw.Close();
fs.Close();
}
【问题讨论】:
-
"sfsdfsdfsdf" 在 UTF-8 中是 ASCII。
标签: c# encoding utf-8 byte-order-mark