Gniewomir Gniewomir - 10 months ago 65
Android Question

Android webview portuguese characters

Characters in my webview are destroyed when i use utf-8. It displays question mark on black diamond background. When I use other encoding they are garbled. I've tried the solution from this thread, my code looks like

input ="xxx.html");
Integer size = input.available();
byte[] buffer = new byte[size];;
text = new String(buffer);

WebSettings settings = webView.getSettings();
webView.loadDataWithBaseURL("file:///android_asset/",text,"text/html; charset=utf-8", "utf-8",null);

the HTML header

<html ><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="xxxxx">

<style type="text/css">
@font-face {
font-family: fonttt;
src: url("file:///android_asset/roboto.ttf")

body {
font-family: fonttt;
font-size: medium;
text-align: justify;

I don't get why utf-8 doesn't work and why when I use other encoding (windows-1252, ISO-8859-1) characters are garbled.


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">&#65;</string>

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


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