21

The speaker icon unicode 1f50a is 5 digits from the "Miscellaneous Symbols and Pictographs" family and when I try and display it I get " a" so apparently I am getting 1f50 (which doesn't exist so blank) followed by "a". I can display any 4 digit unicode character but can't find how to display the longer ones. I know the tablet can display it as I can see it in the Unicode Map app.

        textSound = (TextView)findViewById(R.id.textSound);
    textSound.setText("\u1f50a");
Raedwald
  • 46,613
  • 43
  • 151
  • 237
Allen Edwards
  • 1,488
  • 1
  • 27
  • 44
  • Related question : http://stackoverflow.com/questions/12013341/removing-characters-of-a-specific-unicode-range-from-a-string – Ye Lin Aung Oct 24 '13 at 04:53

1 Answers1

28

These characters cannot be represented directly in a Java string since it uses only 16 bits per character. But there is an escaping mechanism called "surrogate pairs". The character number 1f50a for example can be represented by the two 16 bit 'characters' D83D and DD0A. So something like "\uD83D\uDD0A" might work (I did not try it). It still depends if this character is available in the used font.

This site can help with the conversion.

Henry
  • 42,982
  • 7
  • 68
  • 84
  • Your solution worked. Using the surrogate calculator that you linked to and then putting those unicode pairs back-to-back in a string, allows Android to combine the two into one – heiligbasil May 16 '22 at 20:13