[英]reading stream with right encoding in C#
I'm trying to read a stream with iso-8859-1 encoding with C#: 我正在尝试使用C#读取具有iso-8859-1编码的流:
using (var reader = new StreamReader(stream,System.Text.Encoding.GetEncoding("iso-8859-1")))
{
var current_enc = reader.CurrentEncoding; //value is UTF8
i set the encoding with iso-8859-1 but it's not really set after. 我用iso-8859-1设置了编码,但之后没有真正设置。 Some one has seen this behaviour? 有人看到过这种行为吗?
I find a parameter of StreamReader detectEncodingFromByteOrderMarks. 我找到StreamReader detectEncodingFromByteOrderMarks的参数。 If it is to false, there isn't detect encoding and take yours. 如果为假,则不会检测编码并采用您的编码。
using (StreamReader reader = new StreamReader(stream,System.Text.Encoding.GetEncoding("iso-8859-1"), false))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.