Remix.run Logo
umajho 7 days ago

If you want to get the grapheme length in JavaScript, JavaScript now has Intl.Segmenter[^1][^2].

  > [...(new Intl.Segmenter()).segment(THAT_FACEPALM_EMOJI)].length
  1
[^1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[^2]: https://caniuse.com/mdn-javascript_builtins_intl_segmenter_s...