earni23
03-24-2011, 03:36 PM
Hi
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;
When using the above code 'å', 'ä' and 'ö' appears as '?'. How do I solve this?
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;
When using the above code 'å', 'ä' and 'ö' appears as '?'. How do I solve this?