Open stephen147 opened 3 years ago
U+1F9B0 was introduced in Unicode 11.0.
any workaround?
any workaround?
You can use this library instead which has support for new emoji versions.
The ECMAScript Intl.Segmenter
API has been finished and will be published this year.
Actually, all major browsers, except Firefox (https://bugzil.la/1423593), have supported it since earlier 2021.
If you only work on the latest engines, you can possibly switch to the ECMAScript API.
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
const input = String.fromCodePoint(
0x1f469,
0x200d,
0x1f9b0,
0x1f469,
0x200d,
0x1f469,
0x200d,
0x1f466,
0x200d,
0x1f466,
0x1f3f3,
0xfe0f,
0x200d,
0x1f308
);
const segments = segmenter.segment(input);
const graphemes = Array.from(segments, (s) => s.segment);
console.log(graphemes);
console.log(graphemes.length === 3); // true
try this, the split result is wrong π€±π©βπΌπ§βπΌππββοΈπββοΈππββοΈπββοΈπΆπΆββοΈπΆββοΈπ§π§ββοΈπ§ββοΈπ§π§ββοΈπ§ββοΈπ§βπ¦―π¨βπ¦―π©βπ¦―π§βπ¦Όπ¨βπ¦Όπ©βπ¦Όπ§βπ¦½π¨βπ¦½π©βπ¦½ππββοΈπββοΈππΊ
try this, the split result is wrong π€±π©βπΌπ§βπΌππββοΈπββοΈππββοΈπββοΈπΆπΆββοΈπΆββοΈπ§π§ββοΈπ§ββοΈπ§π§ββοΈπ§ββοΈπ§βπ¦―π¨βπ¦―π©βπ¦―π§βπ¦Όπ¨βπ¦Όπ©βπ¦Όπ§βπ¦½π¨βπ¦½π©βπ¦½ππββοΈπββοΈππΊ
try this code below, it works well
const list = 'π€±π©βπΌπ§βπΌππββοΈπββοΈππββοΈπββοΈπΆπΆββοΈπΆββοΈπ§π§ββοΈπ§ββοΈπ§π§ββοΈπ§ββοΈπ§βπ¦―π¨βπ¦―π©βπ¦―π§βπ¦Όπ¨βπ¦Όπ©βπ¦Όπ§βπ¦½π¨βπ¦½π©βπ¦½ππββοΈπββοΈππΊ'.match(/.[\u{fe0f}\u{1f3fb}-\u{1f3ff}]?(\u{200d}.[\u{fe0f}\u{1f3fb}-\u{1f3ff}]?)*/ug);
console.log(list);
console.log(list.length);
try this, the split result is wrong π€±π©βπΌπ§βπΌππββοΈπββοΈππββοΈπββοΈπΆπΆββοΈπΆββοΈπ§π§ββοΈπ§ββοΈπ§π§ββοΈπ§ββοΈπ§βπ¦―π¨βπ¦―π©βπ¦―π§βπ¦Όπ¨βπ¦Όπ©βπ¦Όπ§βπ¦½π¨βπ¦½π©βπ¦½ππββοΈπββοΈππΊ
try this code below, it works well
const list = 'π€±π©βπΌπ§βπΌππββοΈπββοΈππββοΈπββοΈπΆπΆββοΈπΆββοΈπ§π§ββοΈπ§ββοΈπ§π§ββοΈπ§ββοΈπ§βπ¦―π¨βπ¦―π©βπ¦―π§βπ¦Όπ¨βπ¦Όπ©βπ¦Όπ§βπ¦½π¨βπ¦½π©βπ¦½ππββοΈπββοΈππΊ'.match(/.[\u{fe0f}\u{1f3fb}-\u{1f3ff}]?(\u{200d}.[\u{fe0f}\u{1f3fb}-\u{1f3ff}]?)*/ug); console.log(list); console.log(list.length);
on mac, yes. on win, i don't know is it as well as now, but it wont work last year.
Using emojis like π©βπ¦°π©βπ©βπ¦βπ¦π³οΈβπ
Result:
4