mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
Default stdin script encoding to UTF-8 on Windows
A script read from stdin used the locale encoding, so on a non-UTF-8 console such as CP932 its source encoding differed from a script read from a file, which already defaults to UTF-8. Match both the Prism and legacy paths to magic_comment_spec. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5c649dc36
commit
4f84a740ee
1 file changed
+2
-2
Notes:
git
2026-06-28 23:10:27 +00:00
@@ -2227,7 +2227,7 @@ prism_script(ruby_cmdline_options_t *opt, pm_parse_result_t *result)
|
||||
const bool read_stdin = (strcmp(opt->script, "-") == 0);
|
||||
|
||||
if (read_stdin) {
|
||||
pm_options_encoding_set(options, rb_enc_name(rb_locale_encoding()));
|
||||
pm_options_encoding_set(options, rb_enc_name(IF_UTF8_PATH(rb_utf8_encoding(), rb_locale_encoding())));
|
||||
}
|
||||
if (opt->src.enc.name != 0) {
|
||||
pm_options_encoding_set(options, StringValueCStr(opt->src.enc.name));
|
||||
@@ -2844,7 +2844,7 @@ load_file_internal(VALUE argp_v)
|
||||
enc = rb_enc_from_index(opt->src.enc.index);
|
||||
}
|
||||
else if (f == rb_stdin) {
|
||||
enc = rb_locale_encoding();
|
||||
enc = IF_UTF8_PATH(rb_utf8_encoding(), rb_locale_encoding());
|
||||
}
|
||||
else {
|
||||
enc = rb_utf8_encoding();
|
||||
|
||||
Reference in new issue
Block a user