Skip to content

Conversation

@Earlopain
Copy link
Collaborator

  1. The string starts out as binary
  2. is appended, forcing it back into utf-8
  3. Some invalid byte sequences are tried to append

incompatible character encodings: UTF-8 and BINARY (ASCII-8BIT)

This makes use of my wish to use append_as_bytes. Unfortunatly that method is rather new so it needs a fallback.

It's for #2539. Since ruby-spec has some rather odd-looking code it runs into it.

Copy link
Collaborator

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

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

Could you add this to the polyfills directory? We already have one for byteindex and one for unpack1, so may as well add another one here

1. The string starts out as binary
2. `ち` is appended, forcing it back into utf-8
3. Some invalid byte sequences are tried to append

> incompatible character encodings: UTF-8 and BINARY (ASCII-8BIT)

This makes use of my wish to use `append_as_bytes`. Unfortunatly that method is rather new
so it needs a fallback
@Earlopain Earlopain force-pushed the parser-translator-escaping-invalid-utf8 branch from 9999ef2 to e31e94a Compare January 12, 2025 19:09
@Earlopain
Copy link
Collaborator Author

Works for me, didn't know that was a thing.

I really appreciate how fast you're getting to these. Thanks!

@kddnewton kddnewton merged commit 9074de8 into ruby:main Jan 13, 2025
57 checks passed
@Earlopain Earlopain deleted the parser-translator-escaping-invalid-utf8 branch January 16, 2025 10:18
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