Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display 5 digit unicode characters such as a speaker /u1f50a

Tags:

java

unicode

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");
like image 340
Allen Edwards Avatar asked Oct 24 '13 04:10

Allen Edwards


People also ask

How do I display Unicode?

To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.

What is an example of a Unicode character?

Unicode supports more than a million code points, which are written with a "U" followed by a plus sign and the number in hex; for example, the word "Hello" is written U+0048 U+0065 U+006C U+006C U+006F (see hex chart).

What is a Unicode character on keyboard?

Unicode input is the insertion of a specific Unicode character on a computer by a user; it is a common way to input characters not directly supported by a physical keyboard. Unicode characters can be produced either by selecting them from a display or by typing a certain sequence of keys on a physical keyboard.

How do you find the Unicode of a character?

Suppose a method getUnicode(char c) . A call getUnicode('÷') should return \u00f7 . Characters are already unicode in Java.


1 Answers

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.

like image 141
Henry Avatar answered Sep 29 '22 19:09

Henry