Skip to content

Commit

Permalink
Fixed Encoding.locale_charmap on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Apr 22, 2015
1 parent 9f15d60 commit 8accc1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -2740,7 +2740,7 @@ public Node parseInline(InputStream in, String file, DynamicScope scope) {
addEvalParseToStats();
ParserConfiguration parserConfig =
new ParserConfiguration(this, 0, false, true, false, config);
setupSourceEncoding(parserConfig, getEncodingService().getConsoleEncoding());
setupSourceEncoding(parserConfig, getEncodingService().getLocaleEncoding());
return parser.parse(file, in, scope, parserConfig);
}

Expand Down
Expand Up @@ -137,6 +137,12 @@ public Entry findEncodingOrAliasEntry(byte[] bytes) {

// rb_locale_charmap...mostly
public Encoding getLocaleEncoding() {
final Encoding consoleEncoding = getConsoleEncoding();

if (consoleEncoding != null) {
return consoleEncoding;
}

Entry entry = findEncodingOrAliasEntry(new ByteList(Charset.defaultCharset().name().getBytes()));
return entry == null ? ASCIIEncoding.INSTANCE : entry.getEncoding();
}
Expand Down

0 comments on commit 8accc1d

Please sign in to comment.