Skip to content

[fix] str.split can not handle surrogate pair, replaced with Array.from #395

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

Closed
wants to merge 1 commit into from

Conversation

luoxzhg
Copy link

@luoxzhg luoxzhg commented Mar 2, 2023

example

> Array.from("\n𝐀")
[ '\n', '𝐀' ]
> "\n𝐀".split('')
[ '\n', '\ud835', '\udc00' ]

@ExplodingCabbage
Copy link
Collaborator

Hmm, interesting. I fundamentally agree with the proposed change; operating on Unicode code points instead of UTF-16 code units is the correct default behaviour (and frankly no code should operate on UTF-16 code units unless it's a library explicitly for dealing with UTF-16). However, I don't want to merge any change that modifies the results that jsdiff emits without adding unit tests, adding release notes, and doing a major version number bump. I also want to carefully audit the code line by line to make sure there's nowhere else where we're similarly treating strings as sequences of UTF-16 code units instead of Unicode code points.

I want to churn through some of the more straightforward-to-handle issues and PRs before doing the above - but I do intend to return to this PR in due course!

@ExplodingCabbage
Copy link
Collaborator

Adding docs and stuff over at #500

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

Successfully merging this pull request may close these issues.

2 participants