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

Fix input file encoding #135

Closed
mizunashi-mana opened this issue Jun 8, 2016 · 0 comments
Closed

Fix input file encoding #135

mizunashi-mana opened this issue Jun 8, 2016 · 0 comments

Comments

@mizunashi-mana
Copy link

I got an error such as

/usr/local/bundle/gems/mdl-0.3.1/lib/mdl/doc.rb:31:in `split': invalid byte sequence in US-ASCII (ArgumentError)
    from /usr/local/bundle/gems/mdl-0.3.1/lib/mdl/doc.rb:31:in `initialize'
    from /usr/local/bundle/gems/mdl-0.3.1/lib/mdl/doc.rb:44:in `new'
    from /usr/local/bundle/gems/mdl-0.3.1/lib/mdl/doc.rb:44:in `new_from_file'
    from /usr/local/bundle/gems/mdl-0.3.1/lib/mdl.rb:74:in `block in run'
    from /usr/local/bundle/gems/mdl-0.3.1/lib/mdl.rb:72:in `each'
    from /usr/local/bundle/gems/mdl-0.3.1/lib/mdl.rb:72:in `run'
    from /usr/local/bundle/gems/mdl-0.3.1/bin/mdl:10:in `<top (required)>'
    from /usr/local/bundle/bin/mdl:22:in `load'
    from /usr/local/bundle/bin/mdl:22:in `<main>'

Probably, the reason was LANG=C.
I input UTF-8 file. But, Ruby use US-ASCII from LANG=C, so, String.split try to split "ASCII string".
I fixed this problem by setting env RUBYOPT=-EUTF-8.

However, I suggest guessing file encoding.

Fix: https://github.com/mivok/markdownlint/blob/master/lib/mdl/doc.rb#L44

- self.new(File.read(filename))
+ self.new(Kconv.toutf8(File.read(filename)))

using http://docs.ruby-lang.org/en/2.3.0/Kconv.html#method-c-toutf8

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