Skip to content

Respect encoding option in Prism.lex and friends / Fix ripper encoding handling#4106

Merged
kddnewton merged 2 commits intoruby:mainfrom
Earlopain:lex-encoding
May 8, 2026
Merged

Respect encoding option in Prism.lex and friends / Fix ripper encoding handling#4106
kddnewton merged 2 commits intoruby:mainfrom
Earlopain:lex-encoding

Conversation

@Earlopain
Copy link
Copy Markdown
Collaborator

Two separate fixes for truffleruby/truffleruby#4175:

  • Prism.lex(..., encoding: foo) always created tokens in utf-8 when no magic comment is present, ignoring the passed encoding
  • In Ripper, when no encoding comment is present, the encoding is taken from the passed string instead.

cc @eregon

Earlopain added 2 commits May 8, 2026 21:04
utf-8 is the default for source files but can be overwritten via options
…lator

When no magic encoding comment is present, it does not default to utf-8,
and takes the encoding of the string that contains the source code instead.
Most of the time that will be utf-8, but not always.
Copy link
Copy Markdown
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

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

Thank you!

@kddnewton kddnewton merged commit 1a273db into ruby:main May 8, 2026
61 checks passed
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.

3 participants