Android Webview Utf-8 Not Showing

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");

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");


Related Topics



Leave a reply



Submit