3
回答
C#读取网页拼接处乱码
【腾讯云】学生服务器套餐10元/月 >>>   

在某一个地方如果是中文会有乱码的情况,是代码问题么?

public static string readHtml(Stream stream)
{
	if (stream == null) return "";
	string strBuff = "";
	byte[] bytes = new byte[256];
	int byteRead = 0;
	byteRead = stream.Read(bytes, 0, 256);
	while (byteRead != 0)
	{
		string strResp = Encoding.GetEncoding("gb2312").GetString(bytes, 0, byteRead);
		strBuff = strBuff + strResp;
		byteRead = stream.Read(bytes, 0, 256);
	}
	return strBuff;
}
<无标签>
举报
loveyu
发帖于5年前 3回/152阅
顶部