关闭WebBrowser-Control的自动字符集检测

时间:2014-08-21 09:13:26

标签: c# character-encoding webbrowser-control

我使用此代码设置在WebBrowser-Control中加载的Document的字符集

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

从这里开始:WPF WebBrowser and special characters like german "umlaute"

这通常有效。但是,当我通过WebBrowser-Control的ContextMenu禁用自动字符集检测时,某些文档才显示正确。

我现在正在寻找一种通过代码关闭自动字符集检测的方法。

0 个答案:

没有答案
相关问题