c# - How to get the site content in french language -


i have site content in french language.

now want these through httpwebrequest , httpwebresponse in console application using c#.

public string getcontents(string url) {     streamreader _answer;     try     {         httpwebrequest webreq = (httpwebrequest)webrequest.create(url);         webreq.headers.add(httprequestheader.acceptencoding, "utf-8");         webreq.useragent = "mozilla/4.0 (compatible; msie 6.0;windows nt 5.1;)";         webreq.contenttype = "application/x-www-form-urlencoded";         httpwebresponse webresp = (httpwebresponse)webreq.getresponse();         stream answer = webresp.getresponsestream();         encoding encode = system.text.encoding.getencoding("utf-8");         _answer = new streamreader(answer, encoding.utf8);         return _answer.readtoend();     }     catch     {     }     return ""; } 

i content contain strange symbol squares etc.

are sure web server responding utf-8 encoding?

update:

the web server trying download serving pages character encoding of iso-8859-1 , not utf-8.

you have (a) change hard coded content type or (b) read content type server response , use that.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -