4 ms·
HyperTalk existed before unicode, however it's conceivable that a modern implementation would return... the number of actual characters in a string. For contra
by athenot 6y ago
HyperTalk existed before unicode, however it's conceivable that a modern implementation would return... the number of actual characters in a string.
For contrast, JaveScript's .length definitely does not count the number of characters, it returns the count of UTF-16 units, which for Emojis yields an incorrect result.
My point being that the conveniences we all enjoy with `.length` come with subtle gotchas that we overcome as devs but are perhaps not necessarily as user-friendly as a more long-winded approach.
- cturner 6y agoFor what it's worth, Rust's string length tells you the number of conventional characters, whilst following typical programming notation rules.
- FreeFull 6y agoRust's .len() on string does not give you the length in characters, it gives you the length in bytes. If you want the length in unicode codepoints, you need to do .chars().count(), but given things like combining characters, that might not be quite what you want either.