4 ms·
To make sure I have this right: Graphemes are comprised of code points, code points are comprised of code units, and code units are a chunk of binary of variab
by cmckn 6y ago
To make sure I have this right:
Graphemes are comprised of code points, code points are comprised of code units, and code units are a chunk of binary of variable length depending on the UTF flavor.
UTF-8 uses smaller code units so that strings containing only ASCII (for ex.) are of optimal size (in terms of memory). UTF-32 would mean each "character" takes up 32 bits regardless.
I think the String javadoc could be clearer here. The class overview mentions these concepts but the methods are not as forthcoming.
Thanks!
- didibus 6y agoYou got it. I find this SO does a good concise explanation for them: https://stackoverflow.com/a/27331885/172272 https://stackoverflow.com/a/27331885/172272