Since Java char is 16 bit long, I am wondering how can it represent the full unicode code point?
It can only represent 65536 code points, is that right?
Since Java char is 16 bit long, I am wondering how can it represent
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, a Java char is a UTF-16 code unit. If you need to represent Unicode characters outside the Basic Multilingual Plane, you need to use surrogate pairs within a
java.lang.String. TheStringclass provides various methods to work with full Unicode code points, such ascodePointAt(index).From section 3.1 of the Java Language Specification:
See the
Characterdocs for more information.