News for hackers. Stuff that matters.
Re:How UTF-8 Works by irq-1 on Tuesday February 08, 2022 @02:51PM (#30263626)
> Constant time subscripting is a myth. There's nothing(*) useful to be obtained by adding a fixed offset to the base of your string, in any unicode encoding, including UTF-32.

What about UTF-256? Maybe not today, maybe not tomorrow, but someday...

Re:How UTF-8 Works by ts4z on Tuesday February 08, 2022 @02:58PM (#30263710)
I know you're kidding, but I want to note that UTF-256 isn't enough. There's an Arabic ligature that decomposes into 20 codepoints. That was already in Unicode 20 years ago. You can probably do something even crazier with the family emoji. These make "single characters" that do not have precomposed forms.
Re:How UTF-8 Works by pjscott on Tuesday February 08, 2022 @03:18PM (#30264016)
Also, if you want O(1) indexing by grapheme cluster you can get that with less memory overhead by precomputing a lookup table of the location in the string where you can find every k-th grapheme cluster, for some constant k >= 1. (This requires a single O(n) pass through the string to build the index, but you were always going to have do make at least one such pass through the string for other reasons.)
Re:How UTF-8 Works by wizzwizz4 on Tuesday February 08, 2022 @03:03PM (#30263802)
Some characters are longer than 32 codepoints.