News for hackers. Stuff that matters.
Re:TIL the assumption that string length does not change whe... by AstralStorm on Monday November 22, 2021 @04:11AM (#29304394)
That makes length operation require full parsing of the text according to Unicode rules. Hope you have an up to date set of these!

Codepoints is easy, as are bytes. Graphemes much harder.

So, what's the length of a sole non-breaking joiner codepoint? (U+2060, yes it's allowed)

Re:TIL the assumption that string length does not change whe... by 3np on Monday November 22, 2021 @06:22AM (#29305218)
I’m really not an expert but is there anything particular with this one?

Looking here the answer looks like “0” for all contexts to me.

https://codepoints.net/U+2060

And well, I don’t think anyone’s arguing that a “length” function needs to be exposed by the standard library of any language (I saw that Swift does btw).

Besides from byte count it’s the only interpretation of “length” that I think makes sense for users (like I mentioned above, validating that a name has at least length 1, for example)

Re:TIL the assumption that string length does not change whe... by JohnHaugeland on Monday November 22, 2021 @12:00PM (#29308625)
> And well, I don’t think anyone’s arguing that a “length” function needs to be exposed by the standard library of any language

that's literally the core premise of the original post

Re:TIL the assumption that string length does not change whe... by 3np on Monday November 22, 2021 @02:51PM (#29310862)
...is it?