我正在解析 HTML 站点以在 C# 客户端中使用数据。不幸的是,我的 HTTPresponse 弄乱了所有特殊字符(如法语名称)并用问号“?”替换它们。我可以做些什么来解决我的问题?
这是我的代码:
private void LoadData()
{
String strBaseURL = @"http://here_goes_the_url.com/";
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(strBaseURL);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
while (count > 0);
result = sb.ToString();
}
我试图更改编码,但没有任何结果:(
谢谢!