Android Webview with Garbled Utf-8 Characters

Android WebView with garbled UTF-8 characters.

You can try to edit the settings of your webview before you load the data:

WebSettings settings = mWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");

Also, as provided in the comment below, be sure to add "charset=utf-8" to the loadData call:

mWebView.loadData(getString(R.string.info_texto), "text/html; charset=utf-8", "utf-8");

Android WebView UTF-8 not showing

Use:

mWebView.loadDataWithBaseURL(null, "將賦予他們的傳教工作標示為", "text/html", "utf-8", null);

or using WebSettings with setDefaultTextEncoding:

WebSettings settings = mWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");

For recent versions of Android, API 16 to 22 it was tested and work properly using loadData() method, requires the mimeType to include: "charset=utf-8".

WebView mWebView = (WebView) findViewById(R.id.myWebView);
WebSettings settings = mWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
mWebView.loadData(myCharacters, "text/html; charset=utf-8",null);

or

  mWebView.loadData(myCharacters, "text/html; charset=utf-8","UTF-8");

How to do Character Encoding in a WebView?

After trying all those solutions without success, I ended up trying to just find and replace all the bad characters I could see. That was just too cumbersome and inefficient, but somehow I stumbled on the following two-line fix that did the job for all of it!

In my getHtmlDescription() method, I added these two lines:

description = description.replace("Â", "");
description = Html.fromHtml(description, Html.FROM_HTML_MODE_LEGACY).toString();
return description;

Android webview portuguese characters

You can save them in xml using html-code but, this is mostly not needed if they are in the UTF-8 notation, actual characters will also do:

<string name="my_string">A</string>

Or, you can call setText() with unicode on the TextView:

textView.setText("\u266b");

here this will help you more :
two website that I personally use to write in Icelandic, every single character you rae looking for is listed there

Characters table website 1

Characters table website 2

Non-unicode chars in UTF-8 encoded JSP page in Android Webview

I found an answer here:

${fn:escapeXml(photoTitle)}

Show special characters in a webview

try

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

this ll work on above 4.0.0



Related Topics



Leave a reply



Submit