.NET中使用数据流出现乱码,如何解决?
Stream stream = FileUpload1.PostedFile.InputStream;
StreamReader sr = new StreamReader(stream);
string strLine = sr.ReadLine();
while (strLine != null)
{
Response.Write(strLine);
Response.Write("<br/>");
strLine = sr.ReadLine();
}
sr.Close();
非中文的没问题,中文就变成了乱码。。哎
------解决方案--------------------
StreamReader sr = new StreamReader(stream);
------》
StreamReader sr = new StreamReader(stream, Encoding.GetEncoding("utf-8"));