Bug #7431

Encoding.compatible? results are order-dependent for Strings but not Encodings

Added by Brian Shirai over 1 year ago. Updated over 1 year ago.

[ruby-core:50066]
Status:Rejected
Priority:Normal
Assignee:-
Category:-
Target version:-
ruby -v:ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin10.8.0] Backport:

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".forceencoding "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

History

#1 Updated by Brian Shirai over 1 year 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

#2 Updated by Yusuke Endoh over 1 year ago

  • Status changed from Open to Rejected

Also available in: Atom PDF