2 ms·
Is a String class the right type to use for parsing text formats with lots of fixed length stuff? Maybe Array<UInt8> would be more suitable.
by mikeash 11y ago
Is a String class the right type to use for parsing text formats with lots of fixed length stuff? Maybe Array<UInt8> would be more suitable.
- fauigerzigerk 11y agoThere's a lot of middle ground between parsing a purely structured format and UI oriented string manipulation. Most of what I have done in my life involved semi-structured data with both natural language text and structured parts with fixed lengths. It's extremely inconvenient to have no string functions available when working with byte arrays. I actually like the C approach a lot in principle, because it doesn't make you choose one or the other.
- mikeash 11y agoMaybe it would be best to have a lot of these things we think of as "string" functions available on arrays, like sub-sequence matching, replacement, trimming, even something like regex. Then strings can be "all that, plus unicode."
- fauigerzigerk 11y agoYes, I think that's a good idea.