I'm trying to fetch some data from a web page but i faced character problem. The web page is in utf-8 format and in multi-language, in this case, i can fetch the english based senteces/datas without any problem but for italian, spanish and turkish data, i'm getting wrong characters.
when i check the saved html file, for text coding it says : windows-1254
As you can see in my method i tried to solve the problem by using in streamreader ;
Encoding.GetEncoding("utf-8")
Encoding.Default
Encoding.UTF8
Httpwebrequest :
string postdata = "username" + usern + "&pass=" + pass";
byte[] bytes = new UTF8Encoding().GetBytes(postdata);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.*******.com/login.php");
request.Method = "POST";
request.KeepAlive = true;
request.CookieContainer = cont;
request.AutomaticDecompression = DecompressionMethods.Deflate;
request.CookieContainer.Add(cok);
request.ContentType = "text/html; charset=utf-8";
request.UserAgent = "Mozilla/2.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/9.0";
request.ContentLength = bytes.Length;
request.GetRequestStream().Write(bytes, 0, bytes.Length);
HttpWebResponse response = null;
response = (HttpWebResponse)request.GetResponse();
StreamReader _str2 = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
string html = _str2.ReadToEnd();
File.WriteAllText("login_response.html", html);