string html; HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest; request.UserAgent = Comm.GetRandomUserAgent(); var response = request.GetResponse(); Stream stream = response.GetResponseStream(); byte[] data = new byte[1024]; int count = 1024; StringBuilder sb = new StringBuilder(); MemoryStream ms = new MemoryStream(); do { count = stream.Read(data, 0, 1024); sb.Append(Encoding.UTF8.GetString(data, 0, count)); } while (count >0); stream.Close(); response.Close(); html = sb.ToString(); 问题是如果一个汉字正好在1024的边界上跨两个循环的话这个汉字会成为乱码。大家有什么好的办法可以解决?
- 2 回答
- 0 关注
- 845 浏览
添加回答
举报
0/150
提交
取消