4 ms·
Conversion is the easy part, though. Now try to count the number of "characters" in a string. You will quickly realise that it's much easier to just reach for i
by usrnm 4y ago
Conversion is the easy part, though. Now try to count the number of "characters" in a string. You will quickly realise that it's much easier to just reach for icu, or at least some parts of it
- mlindner 4y agoThat's not something you should be doing anyway. It's not a useful thing to talk about and doesn't even work for all languages. If you are writing some software that requires counting the number of characters in a string you should stop and rethink why you're trying to do what you're doing.
- lultimouomo 4y agoSure, but a) conversion was exactly what was provided but C++11, before they deprecated it b) plenty of staff that the standard library does is complicated! Some of it also seems less fundamental than handling plain text.
- int_19h 4y agoIn practice, counting the number of "characters" turns out to be not all that common, though. This usually comes up doing low-level text rendering or editing, but how often would you do something like that yourself instead of delegating to some library? (and then that library might still reach for ICU - but that's another story)