View Full Version : How to get page source in iso-8859-1 and convert characters to utf8

03-24-2011, 04:36 PM
Im 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();

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;

When using the above code '', '' and '' appears as '?'. How do I solve this?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum