Home » Android » android – Special characters in a TextView

android – Special characters in a TextView

Posted by: admin May 14, 2020 Leave a comment


I want to show the “♫” character in an Android TextView, but it shows [] instead.

This is my code:


How can I display this symbol correctly?

How to&Answers:

You can use an Unicode code: http://unicode-table.com/en/.

Such as:


or alternatively use an iconic font, such as font awesome:

Use this alternative (or any other iconic font you like), in case this character isn’t supported (not all Unicode characters are supported).


Try this:

String str = "♫";
byte spbyte[] = str.getBytes("UTF-8"); 
str = new String( spbyte,"UTF-8");

If it doesn’t work, try this:

String str = "♫";


If nothing else helps, you can either:

  1. use a custom font (e.g.
    http://www.tutorialspoint.com/android/android_custom_fonts.htm or Add custom font for complete android application )

  2. add an image:
    How to add image in a TextView text?


That is common when the source file is encoded as ANSI. Converting the source file as UTF-8 (without BOM) will likely solve the issue.


This seems pretty simple now:

  • Simply go to unicode list
    and choose your unicode and copy go it.

  • Go to strings.xml and paste it.
    enter image description here
    This will paste the unicode character instead of it’s code and use it in your xml as a normal string.

Hope this will help you.


Simply append the symbol as a string in your string.xml
By adding double quotes to the special character.