Some Unicode characters aren't iterated correctly
cbbfcd opened this issue Β· comments
thx! i like this repo, but unicode is a trouble, such as:
type(target, 'cafeΜ', 1000, 'cafe', 1000, loop);
type(target, 'π¨βπ©βπ¦', 1000, 'π¨βπ©βπ§βπ¦', 1000, loop);
I know that some Unicode surrogate pairs aren't handled by String.prototype[Symbol.iterator]
, which is how this library iterates over strings.
Many emoji and other Unicode characters are handled correctly, but some surrogate pairs and diacritics cause an issue. I'd like to handle as many cases as possible without greatly increasing the complexity of the library or introducing a dependency.
One thing I haven't done yet is use String.prototype.normalize
on string arguments. I'm going to use this issue to discuss options. Thank you!
An example of using the String normalize method:
[...'cafeΜ'].length === 5
[...'cafeΜ'.normalize()].length === 4
@camwiegert thx your replay.
i totally agree with you and String.prototype.normalize
is a good idea.