3 ms·
Article is about setting up locale during compilation/runtime. Internally java/jvm uses only UTF-16 and it is not going to change because of backward compatibil
by emergie 9y ago
Article is about setting up locale during compilation/runtime.
Internally java/jvm uses only UTF-16 and it is not going to change because of backward compatibility reasons.
Char is a 16bit type, so some unicode 'characters' have high/low surrogate pairs, those pairs are encoded in 32bit int as `codePoint`.
Example of a problem: String#length returns number of chars, not number of codepoints.
String/Character api is a one big record of utf16 madness:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/lang/String.java#736 http://grepcode.com/file/repository.grepcode.com/java/root/j...
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/lang/Character.java#5180 http://grepcode.com/file/repository.grepcode.com/java/root/j...
Most of contemporary technologies use UTF8 for string encoding and exchange format.
This back and forth UTF8<>UTF16 conversion in java doesn't come without a computational&memory price.