π¨βπ©βπ§ emoji sequence not display right
yurenchen000 opened this issue Β· comments
try on https://susisu.github.io/mte-demo/
/1
paste π¨βπ©βπ§
but shown π¨π©π§
/2
1οΈβ£ display right, but width seems wrong.
some emoji sequence:
'π¨βπ©βπ§'.length -> 8
'π¨βπ©βπ§'.split('') -> (8)
['\uD83D', '\uDC68', 'β', '\uD83D', '\uDC69', 'β', '\uD83D', '\uDC67']
'π¨βπ©βπ§'.match(/\p{Extended_Pictographic}/ug) -> ["π¨","π©","π§"]
'1οΈβ£'.split('') -> (3) ['1', 'οΈ', 'β£']
'2οΈβ£'.split('') -> (3) ['2', 'οΈ', 'β£']
ref:
https://stackoverflow.com/a/64007175/4896468
https://unicode.org/Public/emoji/13.0/emoji-sequences.txt
https://github.com/mathiasbynens/emoji-regex
foud this pkg good at split emoji chars:
const text = `
\u{231A}: β default emoji presentation character (Emoji_Presentation)
\u{2194}\u{FE0F}: βοΈ default text presentation character rendered as emoji
\u{1F469}: π© emoji modifier base (Emoji_Modifier_Base)
\u{1F469}\u{1F3FF}: π©πΏ emoji modifier base followed by a modifier
π¨βπ©βπ§1οΈβ£2οΈβ£
`;
const regex = emojiRegex();
for (const match of text.matchAll(regex)) {
const emoji = match[0];
console.log(`Matched sequence ${ emoji } β code points: ${ [...emoji].length }`);
}
output as expected:
Matched sequence β β code points: 1
Matched sequence β β code points: 1
Matched sequence βοΈ β code points: 2
Matched sequence βοΈ β code points: 2
Matched sequence π© β code points: 1
Matched sequence π© β code points: 1
Matched sequence π©πΏ β code points: 2
Matched sequence π©πΏ β code points: 2
Matched sequence π¨βπ©βπ§ β code points: 5
Matched sequence 1οΈβ£ β code points: 3
Matched sequence 2οΈβ£ β code points: 3
Hi, @yurenchen000.
I am aware of the issues you reported, but this repository is no longer actively maintained.
Fortunately, there is a project that has been forked from this repository and is being actively maintained:
Please give it a try, and consider contributing to it if you are interested :)
Please give it a try, and consider contributing to it if you are interested :)
Thanks, It works perfect !