I'm trying to use WebClient class to view the content of a hebrew page, but get gibberish instead of Hebrew.
My code is:
using (WebClient webClient = new WebClient())
{
webClient.Headers.Add(HttpRequestHeader.ContentType, "charset=windows-1255");
string page = webClient.DownloadString("http://hebrew-academy.huji.ac.il/Pages/default.aspx");
}
I'm receiving the English content correctly, but the Hebrew content is Gibberish for example:
<title> ׳”׳׳§׳“׳׳™׳” ׳׳׳©׳•׳ ׳”׳¢׳'׳¨׳™׳× ג€“ ׳“׳£ ׳”׳'׳™׳×</title>
Does anyone knows how to get the hebrew content correctly?
That page is transmitted as UTF-8, so you should be interpreting it as UTF-8, not as Windows-1255. Do this by setting WebClient.Encoding
to System.Text.Encoding.UTF8
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.