4 ms·
Java characters are 16 bit. Unfortunately many methods in the String API expect strings to be UCS-2 encoded, even though in practice nowadays they're UTF-16. Bu
by alisonatwork 6y ago
Java characters are 16 bit. Unfortunately many methods in the String API expect strings to be UCS-2 encoded, even though in practice nowadays they're UTF-16. But it's more complicated than that, especially since Java 9 which introduced compressed storage for strings that could fit into ISO-8859-1[0].
[0] https://openjdk.java.net/jeps/254 https://openjdk.java.net/jeps/254
- hn_throwaway_99 6y agoThanks for this! I stand corrected. The actual underlying storage switched from a char array to a byte array in Java 9: https://dzone.com/articles/going-beyond-java-8-compact-strings https://dzone.com/articles/going-beyond-java-8-compact-strin...