I got a string from web page title, and show it in winform client application, but the encoding is not right, how to convert it to the right one? Below is my code snippet to convert the title string to system default encoding.
//HAP means HtmlAgilityPack, an HTML parse module.
var hw = new HAP.HtmlWeb();
var doc = hw.Load(url); //Any url of web page.
var title = doc.DocumentNode.SelectSingleNode("//title").InnerText; //Get the title string
var src = doc.Encoding; //Get source encoding, such as UTF8,16, ISO, GB2312 etc.
var dst = System.Text.Encoding.Default; //Local default encoding
title= dst.GetString(System.Text.Encoding.Convert(src, dst, src.GetBytes(title)));//Convert
But the title string isn't show correctly, any problem?