Skip to content

Conversation

Earlopain
Copy link
Contributor

When trying to calculate the width of such strings, it would previously crash with either Encoding::InvalidByteSequenceError or Encoding::UndefinedConversionError. Totally invalid characters are now simply replaced with a replacement character when converting to UTF8.

Especially binary encoded strings (i.e. no encoding) don't make much sense but at least it doesn't crash now and tries to return a sensible default (assume the string is actually valid UTF8

This if for rubocop/rubocop#13618, where such strings started to fail after unicode-display_width v3.

When trying to calculate the width of such strings, it would previously
crash with either `Encoding::InvalidByteSequenceError` or
`Encoding::UndefinedConversionError`. Totally invalid characters are now simply
replaced with a replacement character when converting to UTF8.

Especially binary encoded strings (i.e. no encoding) don't make much sense but at least it doesn't
crash now and tries to return a sensible default (assume the string is actually valid UTF8
@janlelis janlelis merged commit a23a070 into janlelis:main Dec 26, 2024
@janlelis
Copy link
Owner

Thank you, good workarounds!

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.

2 participants