Bug #7431
closedEncoding.compatible? results are order-dependent for Strings but not Encodings
Description
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
Updated by brixen (Brian Shirai) over 11 years ago
Nevermind, I was writing other specs and interchanging Encoding constants and encoding names (eg that #encode and #force_encoding accept). I'm sure no one could ever get confused by these APIs.
You can close the issue.
Cheers,
Brian
Updated by mame (Yusuke Endoh) over 11 years ago
- Status changed from Open to Rejected