.utf16count will get you the number of characters in a simple string[0].
[0] What is a character especially in various non-latin scripts? I think it is well handled in Swift, from what I can see it has been considered carefully but I haven't yet needed to get my head round it.
Edit: Corrected - too fast in the playground and actually checked an array. .utf16count not .count
Comments
.utf16count will get you the number of characters in a simple string[0].
[0] What is a character especially in various non-latin scripts? I think it is well handled in Swift, from what I can see it has been considered carefully but I haven't yet needed to get my head round it.
Edit: Corrected - too fast in the playground and actually checked an array. .utf16count not .count
I believe Apple says to use countElements(string) instead of string.count
Yeah, I understand why they did it, but the fact of the matter is that I'm using ASCII 99% of the time.
But not the rest of the world.