Skip to content

Commit

Permalink
* encoding.c (rb_enc_compatible): return ASCII-8BIT even if 2nd string
Browse files Browse the repository at this point in the history
  is ascii only string. [ruby-core:42354] [Bug ruby#5968]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Feb 5, 2012
1 parent 546eeb5 commit b346d7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Feb 6 00:16:27 2012 NARUSE, Yui <naruse@ruby-lang.org>

* 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 <drbrain@segment7.net>

* lib/webrick.rb: Moved proxy rewriting to WEBrick::HTTPProxy.
Expand Down
1 change: 0 additions & 1 deletion encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/ruby/test_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,8 @@ def test_compatible_p
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

0 comments on commit b346d7a

Please sign in to comment.