News for hackers. Stuff that matters.
Re:UTF-8 String Indexing Strategies by ChrisSD on Thursday May 30, 2019 @05:39AM (#20049643)
> One issue to consider is that strings typically feature random access indexing of code points

True but I find it's much rarer to actually need random access to arbitrary code points. Most of the time I either use strings as opaque "things" or I'm iterating through characters to find something interesting (e.g. parsing) where I can build my own index, if and when necessary.

I do agree with the article that if an abstraction is very leaky it's better to be upfront about that.

Re:UTF-8 String Indexing Strategies by richardwhiuk on Thursday May 30, 2019 @06:34AM (#20049841)
I think that accessing characters by index is _probably_ a code smell in most places, especially if that string may contain arbitrary UTF-8.
Re:UTF-8 String Indexing Strategies by masklinn on Thursday May 30, 2019 @06:43AM (#20049885)
Accessing string content by arbitrary indices is probably an error. Accessing string content by indices you got from previous lookups is useful for a number of situations.
Re:UTF-8 String Indexing Strategies by scatters on Thursday May 30, 2019 @09:35AM (#20050946)
If you have an index from a previous lookup, that can be a byte index.
Re:UTF-8 String Indexing Strategies by raiph on Thursday May 30, 2019 @06:50PM (#20056721)
You're right to the degree that people probably aren't using P6. :)
Re:UTF-8 String Indexing Strategies by ben509 on Thursday May 30, 2019 @10:46AM (#20051699)
It's usually wrong, but you have a large number of people who don't get regular expressions. It's hard to visualize an automata crawling over a string and handing out matches.

The simpler mental model of splitting and splicing is easily grokable, so there's a lot of utility in supporting it.