I have simple code for getting response from websites, but there is one small problem. I am trying to get response from Russian website and from one website I unknown symbols and from other I get normal text. Where might be problem ?
Response from: http://www.kinopoisk.ru
������ � ����…
Response from: http://www.yandex.ru
Греция – Чехия. 1:2…
HttpWebRequest http = (HttpWebRequest) HttpWebRequest.Create("http://");
http.Timeout = 30000;
http.KeepAlive = true;
http.ContentType = "application/x-www-form-urlencoded";
http.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0";
http.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
http.Proxy = null;
WebResponse response = http.GetResponse();
Stream istream = response.GetResponseStream();
StreamReader reader = new StreamReader(istream);
Response.Write(reader.ReadToEnd());
reader.Close();
kinopoisk.ruis encoded asWINDOWS-1251(you can see this in theContent-Typeheader).You need to pass
Encoding.GetEncoding(1251)to the StreamReader to decode that.