Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Unicode characters aren't iterated correctly #8

Open
cbbfcd opened this issue Jan 13, 2020 · 3 comments
Open

Some Unicode characters aren't iterated correctly #8

cbbfcd opened this issue Jan 13, 2020 · 3 comments

Comments

@cbbfcd
Copy link

cbbfcd commented Jan 13, 2020

thx! i like this repo, but unicode is a trouble, such as:

type(target, 'café', 1000, 'cafe', 1000, loop);

type(target, 'πŸ‘¨β€πŸ‘©β€πŸ‘¦', 1000, 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦', 1000, loop);
@camwiegert
Copy link
Owner

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!

@camwiegert camwiegert changed the title wouderful repo, but unicode is a trouble Some Unicode characters aren't iterated correctly Jan 13, 2020
@camwiegert
Copy link
Owner

camwiegert commented Jan 13, 2020

An example of using the String normalize method:

[...'café'].length === 5
[...'café'.normalize()].length === 4

@cbbfcd
Copy link
Author

cbbfcd commented Jan 14, 2020

@camwiegert thx your replay.
i totally agree with you and String.prototype.normalize is a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants