Android. WebView and loadData

Tima picture Tima · Oct 18, 2010 · Viewed 139.2k times · Source

It's possible to use following method for content's setting of a web-view loadData(String data, String mimeType, String encoding)

How to handle the problem with unknown encoding of html data?!

Is there a list of encodings?!

I know from my college that in my case html comes from DB and is encoded with latin-1. I try to set encoding parameter to latin-1, to ISO-8859-1 / iso-8859-1, but still have problem with displaying of special signs like ä, ö, ü.

I'll be very thankful for any advice.

Answer

patryk picture patryk · Feb 16, 2012
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.