4 ms·
> Indexing code points in both UTF-8 and UTF-16 requires reading the whole string up to index location. Substrings are the same as well. Java's String function
by Ded7xSEoPKYNsDd 9y ago
> Indexing code points in both UTF-8 and UTF-16 requires reading the whole string up to index location. Substrings are the same as well.
Java's String functions don't index by Unicode code points, though. Java strings are encoded in UCS-2, or at least the API needs to pretend that they are.
- vardump 9y agoThat can sure lead to interesting bugs!
- Const-me 9y agoRight. Same in C#, C++ STL, and in Apple’s obj-c/swift.
- tjalfi 9y agoSwift takes a different approach than Objective C[0]. [0] https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-swifts-string-api-so-hard.html https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-s...