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

Fixed printable char detection for unicode > 0xFFFF #588

Closed

Conversation

ysavary
Copy link

@ysavary ysavary commented Nov 23, 2020

Fixes #587

rlidwka added a commit that referenced this pull request Dec 1, 2020
@rlidwka rlidwka closed this Dec 1, 2020
@puzrin
Copy link
Member

puzrin commented Dec 1, 2020

Solved in more old-school way - with keeping older browsers support.

@rlidwka
Copy link
Member

rlidwka commented Dec 1, 2020

Thanks for sending this PR.

It didn't quite work for us, since neither Array.from() nor String.prototype.codePointAt() are present in old browsers. So this issue was fixed slightly differently (with polyfill for codePointAt), see 0b2e702.

Array.from() isn't needed here at all, since it can be replaced with an iteration like this:

/*
var chars = Array.from(string);
for (var i = 0; i < chars.length; i++) {
  var code = chars.codePointAt(0);
}
*/

for (var i = 0; i < string.length; i++) {
  var code = string.codePointAt(i);
  if (code >= 0x10000) i++;
}

... which does the same thing, but works faster.

@ysavary
Copy link
Author

ysavary commented Dec 1, 2020

Thank you @rlidwka for your fix !

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

Successfully merging this pull request may close these issues.

dumper.js, why my emojis are escaped ?
3 participants