Hacker News new | past | comments | ask | show | jobs | submit login

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




Thanks 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-strin...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: