0

The question is best explained with the following simple code:

AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("Italiano è" + "   "  + getString(R.string.debug));
ad.show();

where R.stringdebug is exactly the same as "Italiano è". The following is a screenshot of the display:

enter image description here

You can see that the character "è" is displayed correctly only if it is in a string resource.

How can it be displayed correctly in a hard-coded string?

Edit: The result of of using ISO-8859-1 instead of UTF-8 for the java source code file:enter image description here

Hong
  • 17,643
  • 21
  • 81
  • 142
  • I don't know why this happens, but I think you should always use string resources, no? – Sweeper Jun 11 '17 at 20:18
  • 1
    It's probably a problem with the source code file character encoding, see https://stackoverflow.com/a/24568901/8085849 – Julian Goacher Jun 11 '17 at 20:19
  • @Sweeper the app has a very large string resource file. It would take too much space to explain why hard-coded string is preferred in this case. I edited the question to show the result of using ISO-8859-1 instead of UTF-8. – Hong Jun 11 '17 at 20:49

1 Answers1

0

Try This One to handle it, not Tested this code but hope it will work in your case

Html.fromHtml("Italiano è");
Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39