Skip to content

thor files have default encoding of ASCII-8BIT, not UTF-8 #776

@timdiggins

Description

@timdiggins

If you don't specify an encoding a thor file will be read as ASCII-8BIT, (unlike a Ruby file which will be UTF-8)

If you specify an encoding of UTF-8 explicitly, it will be respected.

This is very surprising. Especially when added to rubocop defaults which will not allow an encoding of UTF-8 in a ruby file. (https://docs.rubocop.org/rubocop/1.25/cops_style.html#styleencoding)

Reproduction:
https://github.com/timdiggins/test-thor-encoding

Probably due to using File.binread at https://github.com/rails/thor/blob/main/lib/thor/util.rb#L153 ?

Maybe related to #191.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions