3 ms·
UTF-16 isn't fixed length. It's sort of an extension of UCS-16, which was fixed length, but couldn't give you more than 64k codepoints. Internal representation
by pdpi 5y ago
UTF-16 isn't fixed length. It's sort of an extension of UCS-16, which was fixed length, but couldn't give you more than 64k codepoints. Internal representation is... complicated. java.lang.String uses UTF-16, but .class files use UTF-8.
- pjmlp 5y agoAnd since Java 9 there is some compression going on.
- colejohnson66 5y agoNitpick: UCS counts the bytes, not the bits. So UTF-16, but limited to the BMP, is UCS-2, and UTF-32 is UCS-4.
- pdpi 5y agoOooops. You're absolutely right.