WPF WebBrowser and special characters like german “umlaute”

前端 未结 4 1353
时光取名叫无心
时光取名叫无心 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:59

    This is very quirky.

    1. My solution was to put an explicit meta tag in my HTML file - "My Page.html"

      
      
    2. Then using the standard Web Browser .NET control I then created a URI object first.

      webBrowser1.Url = new Uri("My Page.html");
      
    3. Then draw the page using the refresh method.

      webBrowser1.Refresh();
      

    Note if you use the Navigate method directly it fails to pick up the utf-8 directive, but the URI and refresh approach does.

    Quirky, but it works.

提交回复
热议问题