我尝试使用网络客户端从页面获取文本,但阿拉伯语文本无法正确显示。我已使用以下 url= http://www.elnashra.com/ 尝试了以下代码:
测试1:
WebClient webClient = new WebClient();
Stream s = webClient.OpenRead(urlLink);
StreamReader sr = new StreamReader(s);
测试2:
String utf8 = webClient.DownloadString(webClient, url, Encoding.UTF8);
输出:
������ ����� ����� ������ ������ - Elnashra
最佳答案
尝试以下操作 - 这对我有用:
string url = String.Format("http://www.example.com);
WebClient webClient = new WebClient();
webClient.Encoding = System.Text.Encoding.GetEncoding(1256);
string result = webClient.DownloadString(url);
关于c# - 使用 WebClient 读取阿拉伯语文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42835163/