How can I display a Unicode Character above U+FFFF using char in Java?
I need something like this (if it were valid):
char u = '\u+10FFFF';
String str2 is assigned \uFFFF which is the highest value in Unicode. To convert them into UTF-8, we use the getBytes(“UTF-8”) method.
The 'char' data type in Java originally used for representing 16-bit Unicode. Therefore the size of the char data type in Java is 2 byte, and same for the C language is 1 byte. Hence Java uses Unicode standard. What are features of Java language?
Java actually uses Unicode, which includes ASCII and other characters from languages around the world.
The maximum possible number of code points Unicode can support is 1,114,112 through seventeen 16-bit planes. Each plane can support 65,536 different code points. Among the more than one million code points that Unicode can support, version 4.0 curently defines 96,382 characters at plane 0, 1, 2, and 14.
You can't do it with a single char
(which holds a UTF-16 code unit), but you can use a String
:
// This represents U+10FFFF
String x = "\udbff\udfff";
Alternatively:
String y = new StringBuilder().appendCodePoint(0x10ffff).toString();
That is a surrogate pair (two UTF-16 code units which combine to form a single Unicode code point beyond the Basic Multilingual Plane). Of course, you need whatever's going to display your data to cope with it too...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With