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

Japanese Windows user may see encoding trouble with --format html #1617

Closed
scivola opened this issue Jan 28, 2015 · 3 comments
Closed

Japanese Windows user may see encoding trouble with --format html #1617

scivola opened this issue Jan 28, 2015 · 3 comments

Comments

@scivola
Copy link

scivola commented Jan 28, 2015

rubocop --format html

causes

incompatible character encodings: Windows-31J and UTF-8
(erb):179:in `concat'
(erb):179:in `block (2 levels) in binding'
(erb):171:in `each'
(erb):171:in `block in binding'
(erb):166:in `each'
(erb):166:in `binding'

because

     template = File.read(TEMPLATE_PATH)

does not specify any encoding explicitly.

Solution:

--- lib/rubocop/formatter/html_formatter.rb
+++ lib/rubocop/formatter/html_formatter+.rb
@@ -38,7 +38,7 @@
       def render_html
         context = ERBContext.new(files, summary)

-        template = File.read(TEMPLATE_PATH)
+        template = File.read(TEMPLATE_PATH, encoding: Encoding::UTF_8)
         erb = ERB.new(template, nil, '-')
         html = erb.result(context.binding)
rubocop -V
0.28.0 (using Parser 2.2.0.2, running on ruby 2.1.5 i386-mingw32)
@bbatsov
Copy link
Collaborator

bbatsov commented Jan 28, 2015

Your solution looks good to me. @jonas054 @yujinakayama Do you agree?

@bbatsov
Copy link
Collaborator

bbatsov commented Jan 29, 2015

@scivola Guess you can open a PR.

@jonas054
Copy link
Collaborator

If that works for you @scivola I think it's correct.

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

3 participants