Setting encoding when retrieving webpage

Malfunction

Well-known member
Joined
Dec 8, 2003
Messages
203
Location
Berlin, Germany
hello,

im using this snippet to get the sourcecode of a webpage:

Code:
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(this.currentURL);     
            WebResponse response = myReq.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            String source = reader.ReadToEnd();
            reader.Close();
            response.GetResponseStream().Close();
            this.sourcebox.Text = source;

i guess thats pretty dirty but it works (almost).
trouble is that the encoding is not correct. if the webpages charset is utf-8 the non asci characters are not shown in the textbox.

sorry for posting nubee questions again but i couldnt find a read to use snippet on the net.
 
Back
Top