I can't show arabic on my website, do I have an encoding issue?
I've tried this code on an arabic page :
tmlWeb hw = new HtmlWeb();
HtmlAgilityPack.HtmlDocument htmlDoc = hw.Load(@"http://www.reciter.org/KATHEER/002002.html");
if (htmlDoc.DocumentNode != null)
{
Response.Write(htmlDoc.DocumentNode.SelectSingleNode("//tr/td").InnerText);
}
And the result was something like this : ������ �
How can I resolve this?Update :
This code works fine.
string url = "http://www.reciter.org/KATHEER/002002.html";
string result = null;
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.G开发者_Python百科etEncoding("windows-1256");
result = client.DownloadString(url);
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(result);
if (htmlDoc.DocumentNode != null)
{
Response.Write(htmlDoc.DocumentNode.SelectSingleNode("//tr/td").InnerText);
}
Set your Response encoding.
Response.ContentEncoding
精彩评论