Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicode Supplementary Multilingual Plane in Java

I want to work with SMP(Supplementary Multilingual Plane) in Java. Actually, I want to print a character whose codepoint is more than 0xFFFF. I used this line of code:

int hexCodePoint = Character.toCodePoint('\uD801', '\uDC02' );

to have the codepoint of a special character. But how can I print this unicode character to the console?

Thank you in advance for your help.

like image 349
Shadi Avatar asked Jan 20 '10 18:01

Shadi


1 Answers

String s = new StringBuilder().append("Here is a codepoint: ").appendCodePoint(hexCodePoint).toString();
System.out.println(s);

Note that in Windows it wouldn't produce the expected output due to the limited Unicode capabilities of the console

EDIT: Or Character.toChars(hexCodePoint) to produce char[]

like image 136
axtavt Avatar answered Sep 16 '22 14:09

axtavt