Can I download a webpage with charset=iso-8859-1
, and download it with encoding=utf-8
?
Will it download correctly?
Can I always download with utf-8 encoding for all encodings in the web?
My code:
Html page in the web:
<html debug="true">
<head/>
<body>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<title>Untitled Document</title>
<meta name="robots" content="noindex"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
............
Func:
void download() {
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
worker.ReportProgress(i);
client.DownloadDataAsync(new Uri(link), i);
}
void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) {
Encoding enc = Encoding.UTF8;
string myString = enc.GetString(e.Result);
}