永发信息网

打开网页出现乱字符是怎么回事情?

答案:2  悬赏:40  手机版
解决时间 2021-01-03 04:45
  • 提问者网友:藍了天白赴美
  • 2021-01-02 11:58
我打开QQ空间想重新编辑原来的日志,可是,打开编辑后,网页上出现乱字符,而且,打开个别网页时也会出现乱字符现象,请问这是怎么回事情?我该怎么处理?
最佳答案
  • 五星知识达人网友:撞了怀
  • 2021-01-06 20:04
在页面空白处点右键,选择编码-自动选择(简体中文)
全部回答
  • 1楼网友:青灯有味
  • 2021-01-06 20:38

方法一:webrequest

private string getstringbyurl(string strurl) { webrequest wrt = webrequest.create(strurl); webresponse wrse = wrt.getresponse(); stream strm = wrse.getresponsestream(); streamreader sr = new streamreader(strm, encoding.getencoding("gb2312")); string strallstrm = sr.readtoend(); return strallstrm; }

方法二:httpwebrequest

public static string getpage(string url, encoding encoding) { httpwebrequest request = null; httpwebresponse response = null; streamreader reader = null; try { request = (httpwebrequest)webrequest.create(url); request.useragent = "www.svnhost.cn"; request.timeout = 20000; request.allowautoredirect = false; response = (httpwebresponse)request.getresponse(); if (response.statuscode == httpstatuscode.ok && response.contentlength < 1024 * 1024) { reader = new streamreader(response.getresponsestream(), encoding); string html = reader.readtoend(); return html; } } catch { } finally { if (response != null) { response.close(); response = null; } if (reader != null) reader.close(); if (request != null) request = null; } return string.empty; }

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯