rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.11k stars 552 forks source link

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

Closed timdiggins closed 2 years ago

timdiggins commented 2 years ago

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.

dorner commented 2 years ago

We're happy to look at PRs, hint hint 😄

timdiggins commented 2 years ago

@dorner ok - I got the hint 😉