Unicode is more complicated than that. First of all, there is not a single definition of what the idea of a "single character" even is. It could be code points, composed characters, grapheme clusters, or something else.
However, in practice there are very few situations where a programmer would ever need to make this distinction for arbitrary text. If you give me an example of where you feel that you need to split an arbitrary string by "character", I'm pretty sure I'll be able to counter that with an explanation as to why that is not the right thing to do.
3 comments
[ 4.4 ms ] story [ 16.0 ms ] threadWhat you get from this call is the number of Unicode code points, which doesn't reflect the number of "characters" using any common definition at all.
I'm concerned that misinformed advice like this will lead to even more broken implementations of things like line breaking.
https://play.rust-lang.org/?gist=5d3174958c76718508f6ab45660...
But now I'm curious. Aren't the characters in the example above comprised of multiple Unicode code points?
However, in practice there are very few situations where a programmer would ever need to make this distinction for arbitrary text. If you give me an example of where you feel that you need to split an arbitrary string by "character", I'm pretty sure I'll be able to counter that with an explanation as to why that is not the right thing to do.