Closed Scratchfangs closed 9 months ago
this is also a Scratch issue and a JavaScript issue in general
This happens because string indexing in Scratch uses UTF-16 code units (16 bits each) instead of Unicode code points (what's typically considered a "character"). Using code points would fix this specific case but would make string indexing $O(n)$ since code points aren't all the same length. The even more correct solution would be to use grapheme clusters, which among other things count letters with diacritics as one character and support composed emoji like skin tones and country flags. This would also be $O(n)$.
Yeah, we can't change this without breaking Scratch compatibility, and it would be slow
Seems like something that would work well in an extension
Expected Behavior
Actual Behavior
Steps to Reproduce
Operating System and Browser
Edge 112.0.1722.48, Windows 11