JuliaStrings / InlineStrings.jl

Fixed-width string types for Julia
Other
45 stars 13 forks source link

Fix `chop` on strings with multi-byte graphemes #39

Closed nickrobinson251 closed 2 years ago

nickrobinson251 commented 2 years ago

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 😅