Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding of input file is not respected #645

Open
voxik opened this issue Feb 5, 2019 · 1 comment
Open

Encoding of input file is not respected #645

voxik opened this issue Feb 5, 2019 · 1 comment

Comments

@voxik
Copy link

voxik commented Feb 5, 2019

I wonder what was the intention of #528? I am asking since this fails:

$ LC_ALL=cs_CZ.ISO-8859-2 rspec ./spec/actions/inject_into_file_spec.rb:107
Run options: include {:locations=>{"./spec/actions/inject_into_file_spec.rb"=>[107]}}
F

Failures:

  1) Thor::Actions::InjectIntoFile#invoke! can insert chinese
     Failure/Error: if force || !content.include?(replacement)
     
     Encoding::CompatibilityError:
       incompatible character encodings: ISO-8859-2 and UTF-8
     # ./lib/thor/actions/inject_into_file.rb:102:in `include?'
     # ./lib/thor/actions/inject_into_file.rb:102:in `replace!'
     # ./lib/thor/actions/inject_into_file.rb:57:in `invoke!'
     # ./lib/thor/actions.rb:94:in `action'
     # ./lib/thor/actions/inject_into_file.rb:27:in `insert_into_file'
     # ./spec/actions/inject_into_file_spec.rb:20:in `block in invoke!'
     # ./spec/helper.rb:55:in `capture'
     # ./spec/actions/inject_into_file_spec.rb:20:in `invoke!'
     # ./spec/actions/inject_into_file_spec.rb:108:in `block (3 levels) in <top (required)>'

Finished in 0.01246 seconds (files took 0.31693 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/actions/inject_into_file_spec.rb:107 # Thor::Actions::InjectIntoFile#invoke! can insert chinese

Previously, if nothing else, the encoding of File.binread was given. Now it gets a file of unknown encoding, tries to apply system encoding and do some stuff above it. If the encoding is assumed, then it should be probably specified somewhere or there should be done a conversion.

@voxik
Copy link
Author

voxik commented Feb 5, 2019

BTW it seems that #191 is the same issue.

@voxik voxik changed the title Encoding of input file is not p Encoding of input file is not respected Feb 5, 2019
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

No branches or pull requests

1 participant