6

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.

img

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
Sakaroz
  • 85
  • 1
  • 7

1 Answers1

14

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

Benoit
  • 1,922
  • 16
  • 25
  • 5
    i solve the problem by keeping the doctype, remove the URLEncoder.encode method, and call 2 others methods lika that : webView.getSettings().setDefaultTextEncodingName("utf-8"); webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null); – Sakaroz Jan 05 '12 at 09:12
  • I'm not being able to show the inverted exclamation point (¡, ¡, ¡) using any of these methods. Does anyone know how to work this around? – Cassio Landim Jul 10 '13 at 12:47