3
回答
C#读取网页拼接处乱码
注册华为云得mate10,2.9折抢先购!>>>   

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

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
发帖于4年前 3回/150阅
顶部