It seems to have been broken in some form or fashion forever. Issue 1733
Use loadDataWithBaseURL instead of loadData.
// Pretend this is an html document with those three characters String scandinavianCharacters = "ΓΈΓ¦Γ₯"; // Won't render correctly webView.loadData(scandinavianCharacters, "text/html", "UTF-8"); // Will render correctly webView.loadDataWithBaseURL(null, scandinavianCharacters, "text/html", "UTF-8", null);
Now the part that is really annoying is that on Samsung Galaxy S II (4.0.3) loadData () works just fine, but testing on Galaxy Nexus (4.0.2) distorts multibyte characters if you don't use loadDataWithBaseURL (). WebView Documentation
Latest Android Versions
Some report a change in the behavior of loadData calls requiring mimeType to include charset=utf-8 .
webView.loadData(scandinavianCharacters, "text/html; charset=utf-8", "UTF-8");
You can also use this wording with WebSettings
WebView webView = (WebView) findViewById(R.id.DemoWebView); WebSettings webSettings = webView.getSettings(); webSettings.setDefaultTextEncodingName("utf-8"); webView.loadData(scandinavianCharacters, "text/html; charset=utf-8", null);
Surprisingly, Android still has not resolved this underlying issue.
Cameron Lowell Palmer May 31 '12 at 10:05 a.m. 2012-05-31 10:05
source share