From 299d17a2f1ebda4efba7e634b9a5f7196f5274a8 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 25 Apr 2023 12:00:05 +0100 Subject: [ruby/irb] Fix Locale's encoding lookup for Japanese encodings (https://github.com/ruby/irb/pull/568) In https://github.com/ruby/irb/commit/3ee79e89adb8e21b63d796e53bcc86281685076d, `encoding_aliases.rb` was introduced to return the correct encoding object for `ujis` and `euc` encodings. However, the return value of `@@legacy_encoding_alias_map[@encoding_name]` is always overridden by a second look up with `Encoding.find(@encoding_name)`. So the logic didn't work as expected. This commit fixes the problem. --- test/irb/test_locale.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/irb/test_locale.rb b/test/irb/test_locale.rb index 89c43699cb..053cd234b9 100644 --- a/test/irb/test_locale.rb +++ b/test/irb/test_locale.rb @@ -31,7 +31,7 @@ module TestIRB assert_equal("ja", locale.lang) assert_equal("JP", locale.territory) - assert_equal("UTF-8", locale.encoding.name) + assert_equal(Encoding::EUC_JP, locale.encoding) assert_equal(nil, locale.modifier) assert_include $stderr.string, "ja_JP.ujis is obsolete. use ja_JP.EUC-JP" @@ -47,7 +47,7 @@ module TestIRB assert_equal("ja", locale.lang) assert_equal("JP", locale.territory) - assert_equal("UTF-8", locale.encoding.name) + assert_equal(Encoding::EUC_JP, locale.encoding) assert_equal(nil, locale.modifier) assert_include $stderr.string, "ja_JP.euc is obsolete. use ja_JP.EUC-JP" -- cgit v1.2.1