From b346d7a69cc7e768ee4ac105e53726c87fe1ba0a Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 5 Feb 2012 15:17:50 +0000 Subject: * encoding.c (rb_enc_compatible): return ASCII-8BIT even if 2nd string is ascii only string. [ruby-core:42354] [Bug #5968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ encoding.c | 1 - test/ruby/test_encoding.rb | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 86f0069976..27655a1ec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 6 00:16:27 2012 NARUSE, Yui + + * encoding.c (rb_enc_compatible): return ASCII-8BIT even if 2nd string + is ascii only string. [ruby-core:42354] [Bug #5968] + Fri Feb 3 07:16:47 2012 Eric Hodel * lib/webrick.rb: Moved proxy rewriting to WEBrick::HTTPProxy. diff --git a/encoding.c b/encoding.c index c23a974671..df425f6ebf 100644 --- a/encoding.c +++ b/encoding.c @@ -812,7 +812,6 @@ rb_enc_compatible(VALUE str1, VALUE str2) if (cr2 == ENC_CODERANGE_7BIT) return enc1; } if (cr2 == ENC_CODERANGE_7BIT) { - if (idx1 == ENCINDEX_ASCII) return enc2; return enc1; } } diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb index de96ebd17d..ef2dc39c4d 100644 --- a/test/ruby/test_encoding.rb +++ b/test/ruby/test_encoding.rb @@ -109,5 +109,8 @@ class TestEncoding < Test::Unit::TestCase ua = "abc".force_encoding(Encoding::UTF_8) assert_equal(Encoding::UTF_8, Encoding.compatible?(ua, :abc)) assert_equal(nil, Encoding.compatible?(ua, 1)) + bin = "a".force_encoding(Encoding::ASCII_8BIT) + asc = "b".force_encoding(Encoding::US_ASCII) + assert_equal(Encoding::ASCII_8BIT, Encoding.compatible?(bin, asc)) end end -- cgit v1.2.3