Divide ligature letters such as Thai, Khmer letters and complex emoji into array of graphemes.
You can simply use this library instead of Array.from
to get graphemes.
$ npm install split-graphemes
// An emoji 'π¨βπ©βπ¦βπ¦' consists of 4 people face emoji joined by Zero Width Joiners (ZWJ).
const chars = Array.from('π¨βπ©βπ¦βπ¦') // ['π¨', ZWJ, 'π©', ZWJ, 'π¦', ZWJ, 'π¦']
// It is interpreted exactly as one character!
const chars = splitGraphemes('π¨βπ©βπ¦βπ¦') // ['π¨βπ©βπ¦βπ¦']
Array.from('ααα»αααα·α') // ['α', 'α', 'α»', 'α', 'α', 'α', 'α·', 'α']
splitGraphemes('ααα»αααα·α') // ['ααα»', 'αααα·α']
splitGraphemes('γγγγγ«γγ‘γγ―γ') // ['γγ', 'γγ', 'γ«γ', 'γ‘γ', 'γ―γ']
splitGraphemes('γγγγγγγγγγ') // ['γγ', 'γγ', 'γγ', 'γγ', 'γγ']
splitGraphemes('Hello') // ['H', 'e', 'l', 'l', 'o']
The list of characters is at here.