3 ms·
If you're not using a modern iterator, you'll want string length and string indexing. Otherwise you don't need string lengths except for the reasons given in T
by cryptonector 7y ago
If you're not using a modern iterator, you'll want string length and string indexing. Otherwise you don't need string lengths except for the reasons given in TFA and above, but (1) (to allocate memory) can be hidden in most cases, (2) is mostly not necessary (account for encoded bytes where possible and be done), and there's very little code that needs to figure out (3).
For almost every task, an iterator that iterates graphemes (extended grapheme clusters) is the right thing to do.
I do think it's annoying that Unicode ended up with such a complex extended grapheme cluster scheme though.