[Bug 38189] Multiple applications want 'IHTMLDocument2::put_charset' implementation (Yarxi dictionary, iPed 7G 2019)

wine-bugs at winehq.org wine-bugs at winehq.org
Tue Oct 16 16:30:50 CDT 2018


https://bugs.winehq.org/show_bug.cgi?id=38189

--- Comment #10 from Anastasius Focht <focht at gmx.net> ---
Hello Jacek,

--- quote ---
It's not clear to me how this is supposed to work on already loaded document.
Does the attached hack help?
--- quote ---

sure it helps. No dialog box for the first app, no first chance exception
(harmless) for the other app.

If properly implemented, the charset property is taken into account upon next
reload/refresh. I found a discussion related to the topic: "web browser
control: cannot change encoding/charset":

https://stackoverflow.com/questions/9039932/c-web-browser-control-cannot-change-encoding-charset

--- quote ---
Here's what eventually worked:

In the handler of the "NavigateComplete2" browser event,

    the charset is modified using the charset property,
    then the META tag is thrown away by setting its outerHTML to empty string,
    and then the control is refreshed.

Modifying the order of these actions, or omitting a step, will render the
entire operation void. MSHTML is picky.
--- quote ---

Reference Source:

https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/WebBrowser.cs,1952

--- snip ---
public void DocumentComplete(object pDisp, ref object urlObject) {

  Debug.Assert(urlObject == null || urlObject is string, "invalid url");
  haveNavigated = true;

  if (this.parent.documentStreamToSetOnLoad != null && (string)urlObject ==
"about:blank") {
      HtmlDocument htmlDocument = this.parent.Document;
      if (htmlDocument != null) {
          UnsafeNativeMethods.IPersistStreamInit psi = htmlDocument.DomDocument
as UnsafeNativeMethods.IPersistStreamInit;
          Debug.Assert(psi != null, "The Document does not implement
IPersistStreamInit");
          UnsafeNativeMethods.IStream iStream =
(UnsafeNativeMethods.IStream)new UnsafeNativeMethods.ComStreamFromDataStream(
                                      this.parent.documentStreamToSetOnLoad);
          psi.Load(iStream);
          htmlDocument.Encoding = "unicode";
      }
      this.parent.documentStreamToSetOnLoad = null;
  }
  else {
      string urlString = urlObject == null ? "" : urlObject.ToString();
      WebBrowserDocumentCompletedEventArgs e = new
WebBrowserDocumentCompletedEventArgs(
              new Uri(urlString));
      this.parent.OnDocumentCompleted(e);
  }
}
--- snip ---

https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/HtmlDocument.cs,e0758ec7ee4f7d98

--- snip ---

        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public string Encoding
        {
            get
            {
                return this.NativeHtmlDocument2.GetCharset();
            }
            set
            {
                this.NativeHtmlDocument2.SetCharset(value);
            }
        }
--- snip ---

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list