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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong default encoding for loading code snippets #1171

Closed
ddfreyne opened this Issue Apr 29, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@ddfreyne
Member

ddfreyne commented Apr 29, 2017

Steps to reproduce

  1. Set environment in encoding to ASCII
  2. Add some UTF-8 content to lib/ (e.g. 馃敟 = 'hot')
  3. Compile site

Expected behavior

No crash.

Code snippets are loaded with the explicitly stated encoding at the top of the file (e.g. # encoding: utf-8), or UTF-8 if no encoding is specified.

Actual behavior

Crash.

SyntaxError: lib/hi.rb:1: invalid multibyte char (US-ASCII)

Code snippets are loaded with the encoding defined in the environment.

Details

This also applies to Rules, Checks, and commands defined in commands/.

An initial step would be to interpret the contents as UTF-8 (which Ruby defaults to anyway), but a better approach would be to infer the encoding from the initial line, looking for encoding/coding.

CC @josh-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment