C# HtmlAgilityPack HtmlDocument() LoadHtml encoding

c#, encoding

Solution

Use `DownloadData` method of WebClient instead of `DownloadString()`:

WebClient client = new WebClient();
var data = client.DownloadData(url);
var html = Encoding.UTF8.GetString(data);

Problem

``` Uri url = new Uri("http://localhost/rgm.php"); WebClient client = new WebClient(); string html = client.DownloadString(url); HtmlAgilityPack.HtmlDocument doc23 = new HtmlAgilityPack.HtmlDocument(); doc23.LoadHtml(html); HtmlNode body23 = doc23.DocumentNode.SelectSingleNode("//body"); string content23 = body23.InnerHtml; ``` How can i force this to parse web page with "UTF-8" encoding?

Original source