Issue #7431 has been updated by mame (Yusuke Endoh).

Status changed from Open to Rejected


----------------------------------------
Bug #7431: Encoding.compatible? results are order-dependent for Strings but not Encodings
https://bugs.ruby-lang.org/issues/7431#change-33847

Author: brixen (Brian Ford)
Status: Rejected
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin10.8.0]


Could someone please explain the following?

1.9.3p286 :001 > Encoding.compatible? "euc-jp", "utf-8"
 => #<Encoding:UTF-8> 
1.9.3p286 :002 > Encoding.compatible? "utf-8", "euc-jp"
 => #<Encoding:UTF-8> 
1.9.3p286 :003 > a = "a".force_encoding "utf-8"
 => "a" 
1.9.3p286 :004 > b = "b".force_encoding "euc-jp"
 => "b" 
1.9.3p286 :005 > Encoding.compatible? a, b
 => #<Encoding:UTF-8> 
1.9.3p286 :006 > Encoding.compatible? b, a
 => #<Encoding:EUC-JP> 
1.9.3p286 :007 > Encoding.compatible? a, "euc-jp"
 => #<Encoding:UTF-8> 
1.9.3p286 :008 > Encoding.compatible? "euc-jp", a
 => #<Encoding:UTF-8> 
1.9.3p286 :009 > Encoding.compatible? b, "utf-8"
 => #<Encoding:EUC-JP> 
1.9.3p286 :010 > Encoding.compatible? "utf-8", b
 => #<Encoding:UTF-8> 

Thanks,
Brian


-- 
http://bugs.ruby-lang.org/