请问如何强制设置保存的编码方式为UTF-8?
4 个解决方案
#1
FileStream stream = new FileStream("", FileMode.Open);
string value = "aasa";
byte[] data = Encoding.GetEncoding("UTF-8").GetBytes(value);
stream.Write(data,0,data.Length);
或者用streamWriter指定
streamWriter writer=new streamWriter(stream,Encoding.GetEncoding("UTF-8"));
#2
用Encoding.UTF8获取utf-8格式,然后再用FileStream输出。
#3
好东西啊..
#4
没看明白...具体该怎么用
#1
FileStream stream = new FileStream("", FileMode.Open);
string value = "aasa";
byte[] data = Encoding.GetEncoding("UTF-8").GetBytes(value);
stream.Write(data,0,data.Length);
或者用streamWriter指定
streamWriter writer=new streamWriter(stream,Encoding.GetEncoding("UTF-8"));
#2
用Encoding.UTF8获取utf-8格式,然后再用FileStream输出。
#3
好东西啊..
#4
没看明白...具体该怎么用