Search code examples
c#webbrowser-controldiacriticsmhtml

WPF WebBrowser and special characters like german "umlaute"


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, that this charactes are not shown correct. How can I solve this?

Best Regards, Thomas


Solution

  • 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();
        }