Closed sindresorhus closed 7 years ago
It seems to think surrogate pair character width is 1. For example this string 🎂🎂🎂🎂
has a width of 8, but slicing from 0 to 4 returns the entire string.
const string = '🎂🎂🎂🎂';
sliceAnsi(string, 0, 4); // => '🎂🎂🎂🎂'
sliceAnsi(string, 0, 2); // => '🎂🎂'
I would have expected this:
const string = '🎂🎂🎂🎂';
sliceAnsi(string, 0, 4); // => '🎂🎂'
sliceAnsi(string, 0, 2); // => '🎂'
sliceAnsi(string, 0, 8); // => '🎂🎂🎂🎂'
Can this be re-opened?
https://mathiasbynens.be/notes/javascript-unicode
I've added a failing skipped test: https://github.com/chalk/slice-ansi/commit/fab456095107f514031f7ae73ced26249d6c9691
Same as https://github.com/chalk/wrap-ansi/issues/11.