显然,谷歌的编码是 UTF-8,因为它在它的 html 元标记中说明。但是当我使用 ASP WebRequest.GetResponse() 打开 scharfes+s 的搜索页面时,它充满了无法识别的字符。有人知道那里发生了什么吗?
为方便起见,代码粘贴在下面
页面
<form id="form1" runat="server">
<div>
<div runat="server" id="output"/>
</div>
</form>
代码隐藏
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text;
public partial class SearchEngineCaller : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpWebRequest queryPage = (HttpWebRequest)WebRequest.Create("https://www.google.com/search?q=scharfes+s");
queryPage.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)queryPage.GetResponse();
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
output.InnerHtml = readStream.ReadToEnd();
}
}
我应该使用什么编码?