Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
03-24-2011, 03:36 PM #1
- Join Date
- Feb 2010
- Thanked 0 Times in 0 Posts
How to get page source in iso-8859-1 and convert characters to utf8
I´m getting the page source with the following code, but its in "iso-8859-1" and I want to convert it to utf-8.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www...."); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream receiveStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(receiveStream); String text = readStream.ReadToEnd(); response.Close(); readStream.Close(); Encoding iso = Encoding.GetEncoding("iso-8859-1"); Encoding utf8 = Encoding.UTF8; byte isoBytes = iso.GetBytes(text); byte utf8Bytes = Encoding.Convert(iso, utf8, isoBytes); string output = utf8.GetString(utf8Bytes); TextArea.Text = output;