license const isNotJapaneseRegex = /[^0-9A-Z○◯々-〇〻ぁ-ゖゝ-ゞァ-ヺー０-９Ａ-Ｚｦ-ﾝ\p{Radical}\p{Unified_Ideograph}]+/gimu ; export default function getCharacterCount ( node ) { if ( ! node . textContent ) { return 0 ; } return countUnicodeCharacters ( node . textContent . replace ( isNotJapaneseRegex , '' ) ) ; } /**
 * Because '𠮟る'.length = 3
 * Reference: https://dmitripavlutin.com/what-every-javascript-developer-should-know-about-unicode/#length-and-surrogate-pairs
 */ function countUnicodeCharacters ( s ) { return [ ... s ] . length ; }