https://bugs.winehq.org/show_bug.cgi?id=38189
--- Comment #10 from Anastasius Focht focht@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-cha...
--- 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...
--- 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...
--- snip ---
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public string Encoding { get { return this.NativeHtmlDocument2.GetCharset(); } set { this.NativeHtmlDocument2.SetCharset(value); } } --- snip ---
Regards