How to count the correct length of a string with emojis in javascript?
str.length gives the count of UTF-16 units. Unicode-proof way to get string length in codepoints (in characters) is […str].length as iterable protocol splits the string to codepoints. If we need the length in graphemes (grapheme clusters), we have these native ways: a. Unicode property escapes in RegExp. See for example: Unicode-aware version of \w or … Read more