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

Fix chop on strings with multi-byte graphemes #39

Merged
merged 1 commit into from
Oct 2, 2022

Conversation

nickrobinson251
Copy link
Collaborator

@nickrobinson251 nickrobinson251 commented Sep 30, 2022

Before we were calculating the new "length" of the string accidentally assuming all "characters" were 1 codeunit and not adjusting this to consider "characters" that take more than 1 codeunit (possibly because of how the Base.chop(::AbstractString) method delegates this final adjustment to the SubString constructor)

I think this is now correct for strings with multi-byte "characters" anywhere in the string... but this stuff make my head hurt so i'm mostly relying on testcases for that and someone should double-check the logic 😅

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; thanks @nickrobinson251!

@quinnj quinnj merged commit 21e4791 into JuliaStrings:main Oct 2, 2022
@nickrobinson251 nickrobinson251 deleted the npr/38-chop-multibyte branch October 3, 2022 23:20
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.

chop() doesn't work with StringX
2 participants