I think I can use \u**** to construct a character based on UTF16, how to construct a string using UTF8?
I think I can use \u**** to construct a character based on UTF16, how
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.
Strings in Java are encoding-agnostic (they use UTF-16 internally, but that doesn’t matter here). The codes you are entering after
\uare Unicde code points, they are not the actual binary representation of characters. Each character has an associated code point. Different encodings define how you map code points to given binary represantation.That being said you construct string using code points and then convert it to arbitrary encoding using
getBytes()method. For example Euro sign (€):Worth to remember: UTF-16 isn’t really using 16 bits all the time!