Hacker News new | past | comments | ask | show | jobs | submit login

> * The overwhelming majority of languages don't give you code-point level iteration over strings by default (and you probably want grapheme), most opting for code units — which is what an unsigned char ptr in C containing UTF-8 data will give you. (C++, Java, C#, Python < 3.3, and JavaScript all fall in this bucket)

Saying for (let ch of str) in JavaScript iterates over the codepoints, not UCS-2 codepoints.




TIL! (Though, note that both indexing and .length operate in code units in JS.)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: