Encoding issue with WebView's loadData Encoding issue with WebView's loadData android android

Encoding issue with WebView's loadData


myWebView.loadData(myHtmlString, "text/html; charset=UTF-8", null);

This works flawlessly, especially on Android 4.0, which apparently ignores character encoding inside HTML.

Tested on 2.3 and 4.0.3.

In fact, I have no idea about what other values besides "base64" does the last parameter take. Some Google examples put null in there.

You should always use UTF-8 encoding. Every other character encoding has become obsolete for many years already.


Only way to have it working, as commented here:

webview.loadDataWithBaseURL("fake://not/needed", html, "text/html", "utf-8", "");

No URI encoding, utf-8... loadData bug?


String start = "<html><head><meta http-equiv='Content-Type' content='text/html' charset='UTF-8' /></head><body>";String end = "</body></html>";webcontent.loadData(start+ YOURCONTENT + end, "text/html; charset=UTF-8", null);

One of solution of problem.