I know this problem has been documented elsewhere but the solutions don't seem to work for me. Other similar questions:
Android WebView with garbled UTF-8 characters.
Android WebView UTF-8 not showing
I'm essentially trying to show the minus/plus character (∓) in an android webview. I tested several other characters 'around' the minus plus character in the UTF-8 table but some of them didn't work either
Here is the java im using:
final WebView w = (WebView) findViewById(R.id.webview1);
w.getSettings().setJavaScriptEnabled(true);
w.getSettings().setDefaultTextEncodingName("utf-8");
InputStream is;
try {
is = getAssets().open("test5.html");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String str = new String(buffer);
w.loadData(str, "text/html; charset=utf-8", "utf-8");
Here is the html test5.html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
char: ∓ <br/>
char: ∔ <br/>
char: ∕ <br/>
char: ∖ <br/>
char: ∗ <br/>
char: ∘ <br/>
</body>
The only characters that show up are the "∕" and "∗". I've also tried
w.loadDataWithBaseURL("file:///doesnotmatter", str, "text/html", "utf-8", "");
with no success. I'm not too familiar with the input stream thing so I don't know if there's something wrong there. Please help, its taken me awhile =\
-Teneth