UTF-8 encoding on WebView and ICS

2019-04-08 05:21发布

问题:

To correctly display UTF-8 text in a WebView, I usually use a doctype and a meta tag :

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

and I use a tip I've seen on Stack Overflow:

string = URLEncoder.encode(string, "UTF-8").replaceAll("\\+", " ");

That works fine on Gingerbread and older Android versions, but my Nexus S recently received the Ice Cream Sandwich update, and French characters like é, à, è, etc. are displayed like this: é, for example.

I don't know if the ISO-xxxx-1 encoding is the solution, but if someone had the same problem, please share.

回答1:

Try using the method loadDataWithBaseURL with random String for the other params instead of loadData