3 ms·
Isn't the access to the views an iterator? > I'm not sure there is a good case for parsing in a non-unicode-aware way I'm not saying that you should parse in
by Manishearth 10y ago
Isn't the access to the views an iterator?
> I'm not sure there is a good case for parsing in a non-unicode-aware way
I'm not saying that you should parse in a non-unicode-aware way, I'm saying that most parsing code deals with ASCII delimeters, so grapheme clusters are a distraction (and will mess up parsing, since most formats do not consider EGCs. An HTML closing tag followed by an accent would totally break the parser otherwise). You rarely need to index, though.
Basically, in parsing, you're looking for characters which themselves are single code points. So it doesn't matter.
> If you're working with strings as opaque data
Well, not entirely opaque :)
But the String type is basically "here is a valid piece of UTF8 data", and you can pass that around. That's a distinct enough purpose to have a String type, even if you don't mess with its innards.
IME the most used String APIs are those for interpolation, concatenation, and search, all of which don't need to be EGC aware (though search being EGC aware is sometimes a good thing). Slicing sometimes gets used in conjunction with the others.