JavaScript ♥ Unicode
summary
JavaScript treats Unicode astral code points as surrogate pairs so .length and naive split/reverse return wrong results, which breaks things like Twitter’s old counter (emoji counted as two) and can even corrupt data. ES2015 adds exact fixes: \u{...} escapes, String.fromCodePoint, string iterators (and the spread operator) and codePointAt, plus normalization (NFC) to collapse equivalent forms. For regexes use the new u flag or build patterns with tools like regenerate; a transpiler rewrites u‑flag regexes for older engines.
AI-written summary · about
chapters (15)
- 0:00Introduction and speaker intro
- 0:37About the presenter
- 1:59JavaScript Unicode challenges
- 3:46Unicode basics for JavaScript
- 7:21Character encodings overview
- 10:33Escape sequences in JavaScript
- 14:27Surrogate pairs explained
- 18:20Counting code points accurately
- 23:59Reversing strings with Unicode
- 26:52Creating strings from code points
- 29:43Iterating over Unicode strings
- 30:03Regex dot operator limitations
- 34:40Regex character class ranges
- 37:51Summary and workarounds
- 38:55Q&A session
