[Webkit-unassigned] [Bug 186797] WebView reload emojis messy

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jun 21 17:10:15 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=186797

--- Comment #16 from Myles C. Maxfield <mmaxfield at apple.com> ---
When you say "String(contentsOfFile: htmlPath!, encoding: .utf8)" you are telling Foundation to read the file, interpret the bytes as UTF-8, and convert the string to some well-known encoding so it can be held in memory. All strings use the same well-known encoding. Everything works so far.

Then, when you use "WKWebView.loadHTMLString(_:baseURL:)", WebKit does two things:

1) Reads the string in its (correct) internal encoding, and draws the emoji properly.
2) Remembers the baseURL

Then, if the Javascript then executes "window.location.reload()", WebKit will load from the baseURL it remembered. At this point, the string argument to "WKWebView.loadHTMLString(_:baseURL:)" is totally lost forever. From now on, WebKit only uses the baseURL.

So, when the content reloads, it reloads from the baseURL. Upon reading the file, however, WebKit doesn't know what encoding to use, so it arbitrarily picks one, and happens to pick wrong. Adding <meta charset="utf-8"> is the way to tell WebKit the correct encoding.

I've attached the fixed project. It's fixed by adding <meta charset="utf-8"> in the HTML file.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180622/15e76ed8/attachment.html>


More information about the webkit-unassigned mailing list