News for hackers. Stuff that matters.
Re:TIL the assumption that string length does not change whe... by masklinn on Monday November 22, 2021 @01:50AM (#29303581)
In Swift a character is a grapheme cluster, and so the length (count) of a string is in fact the number of grapheme clusters it contains.

The number of codepoints (which is almost always useless but what some languages return) is available through the unicodeScalars view.

The number of code units (what most languages actually return, and which can at least be argued to be useful) is available through the corresponding encoded views (utf8 and utf16 properties)

Re:TIL the assumption that string length does not change whe... by garmaine on Monday November 22, 2021 @05:57PM (#29312616)
The more I learn about swift, the more I like it.