Reputation: 2082
My program reads a web page content with by issuing a HttpWebRequest and reading a stream from HttpWebResponse.
I looked at the html content and saw this.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
So I did this:
Encoding CorrectEncoding = Encoding.GetEncoding("iso-8859-1");
StreamReader readStream = new StreamReader(receiveStream, CorrectEncoding);
result = readStream.ReadToEnd();
But inside result
instead of seing Björn as in the browser I see Bj?rn.
Any idea what I am doing wrong?
Thank you
Upvotes: 0
Views: 209
Reputation: 116108
Use HttpWebResponse's headers
response.Headers[HttpResponseHeader.ContentType]
or
response.Headers[HttpResponseHeader.ContentEncoding]
instead of looking into stream.
Upvotes: 1