WPF WebBrowser and special characters like german “umlaute”

前端 未结 4 1362
时光取名叫无心
时光取名叫无心 2020-12-10 22:56

I use the WPF WebBrowser Control in my app. I have a file (mht) which contains german umlaute (ä ö ü). Now, I load this this file with .Navigate(path) but the Problem is, th

4条回答
  •  感动是毒
    2020-12-10 23:38

    I have solved it with the following:

        static void webBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) {
            var webBrowser = sender as WebBrowser;
            if(webBrowser == null) {
                return;
            }
            var doc = (IHTMLDocument2)webBrowser.Document;           
    
            doc.charset = "utf-8";
            webBrowser.Refresh();
        }
    

提交回复
热议问题