|
| 1 | +From 6f21c171d61a4e1b9dca020d6d3eae89bb0d2d90 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Thu, 6 Apr 2023 14:30:27 -0700 |
| 4 | +Subject: [PATCH] Revert "Set default for Encoding.default_external to UTF-8 on |
| 5 | + Windows (#2877)" |
| 6 | + |
| 7 | +This reverts commit 94b6933d1c6f4c8698319fbcac9dcecc9033b4b9. |
| 8 | +--- |
| 9 | + encoding.c | 4 +--- |
| 10 | + ruby.c | 4 ++-- |
| 11 | + spec/ruby/command_line/dash_upper_k_spec.rb | 4 ++-- |
| 12 | + spec/ruby/library/stringio/binmode_spec.rb | 2 +- |
| 13 | + 4 files changed, 6 insertions(+), 8 deletions(-) |
| 14 | + |
| 15 | +diff --git a/encoding.c b/encoding.c |
| 16 | +index 8bfab73177..29d3f5fdbb 100644 |
| 17 | +--- a/encoding.c |
| 18 | ++++ b/encoding.c |
| 19 | +@@ -1587,9 +1587,7 @@ rb_enc_default_external(void) |
| 20 | + * File data written to disk will be transcoded to the default external |
| 21 | + * encoding when written, if default_internal is not nil. |
| 22 | + * |
| 23 | +- * The default external encoding is initialized by the -E option. |
| 24 | +- * If -E isn't set, it is initialized to UTF-8 on Windows and the locale on |
| 25 | +- * other operating systems. |
| 26 | ++ * The default external encoding is initialized by the locale or -E option. |
| 27 | + */ |
| 28 | + static VALUE |
| 29 | + get_default_external(VALUE klass) |
| 30 | +diff --git a/ruby.c b/ruby.c |
| 31 | +index f549e72fd0..1a1007dcce 100644 |
| 32 | +--- a/ruby.c |
| 33 | ++++ b/ruby.c |
| 34 | +@@ -2026,7 +2026,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) |
| 35 | + enc = rb_enc_from_index(opt->ext.enc.index); |
| 36 | + } |
| 37 | + else { |
| 38 | +- enc = IF_UTF8_PATH(uenc, lenc); |
| 39 | ++ enc = lenc; |
| 40 | + } |
| 41 | + rb_enc_set_default_external(rb_enc_from_encoding(enc)); |
| 42 | + if (opt->intern.enc.index >= 0) { |
| 43 | +@@ -2146,7 +2146,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) |
| 44 | + enc = rb_enc_from_index(opt->ext.enc.index); |
| 45 | + } |
| 46 | + else { |
| 47 | +- enc = IF_UTF8_PATH(uenc, lenc); |
| 48 | ++ enc = lenc; |
| 49 | + } |
| 50 | + rb_enc_set_default_external(rb_enc_from_encoding(enc)); |
| 51 | + if (opt->intern.enc.index >= 0) { |
| 52 | +diff --git a/spec/ruby/command_line/dash_upper_k_spec.rb b/spec/ruby/command_line/dash_upper_k_spec.rb |
| 53 | +index 7e71532295..a060eab793 100644 |
| 54 | +--- a/spec/ruby/command_line/dash_upper_k_spec.rb |
| 55 | ++++ b/spec/ruby/command_line/dash_upper_k_spec.rb |
| 56 | +@@ -58,8 +58,8 @@ |
| 57 | + end |
| 58 | + |
| 59 | + it "ignores unknown codes" do |
| 60 | +- external = Encoding.find('external') |
| 61 | ++ locale = Encoding.find('locale') |
| 62 | + ruby_exe(@test_string, options: '-KZ').should == |
| 63 | +- [Encoding::UTF_8.name, external.name, nil].inspect |
| 64 | ++ [Encoding::UTF_8.name, locale.name, nil].inspect |
| 65 | + end |
| 66 | + end |
| 67 | +diff --git a/spec/ruby/library/stringio/binmode_spec.rb b/spec/ruby/library/stringio/binmode_spec.rb |
| 68 | +index 853d9c9bd6..83178787f3 100644 |
| 69 | +--- a/spec/ruby/library/stringio/binmode_spec.rb |
| 70 | ++++ b/spec/ruby/library/stringio/binmode_spec.rb |
| 71 | +@@ -9,7 +9,7 @@ |
| 72 | + |
| 73 | + it "changes external encoding to BINARY" do |
| 74 | + io = StringIO.new |
| 75 | +- io.external_encoding.should == Encoding.find('external') |
| 76 | ++ io.external_encoding.should == Encoding.find('locale') |
| 77 | + io.binmode |
| 78 | + io.external_encoding.should == Encoding::BINARY |
| 79 | + end |
| 80 | +-- |
| 81 | +2.37.1 (Apple Git-137.1) |
| 82 | + |
0 commit comments