3 ms·
> You deal with strings as bytes (opaque data) more often than strings as text in systems programming, basically. Now you're really confusing me. Are you talki
by scrollaway 10y ago
> You deal with strings as bytes (opaque data) more often than strings as text in systems programming, basically.
Now you're really confusing me. Are you talking about simply byte strings vs. unicode strings? Most modern languages, including python, have that distinction. What am I missing?
- Manishearth 10y agoNo, no, Rust has unicode (utf8) strings (also bytestrings if you need them). "bytes" was a mischaracterization, sorry. I'm saying that most string handling in Rust is just lugging them around and copying them and concatenating/interpolating them. On top of that, the few times you do iterate through them, you're looking for specific characters or character sequences (e.g. while parsing), and EGCs aren't so important there. They can be, but usually aren't. Basically, personally the only times I've seen .chars() being used is in parsery things (where your grammar is defined over code points, not EGCs, so using EGCs is counterproductive and wrong), in the Servo DOM (where the spec tells you to operate on chars), and code where you're just verifying that the string contains or does not contain code points of a certain type (e.g. whitespace). None of this is ascribing meaning to the concept of a code point, it's just using them as a crutch to reason about things like equality. (Of course, equality in Unicode is a whole other can of worms).