Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

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

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");
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 "uD83DuDD0A" 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...