Project

General

Profile

Bug #7431

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

Added by Brian Shirai about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
ruby -v:
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin10.8.0]
Backport:
2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
[ruby-core:50066]

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

History

#1 [ruby-core:50067] Updated by Brian Shirai about 3 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

#2 [ruby-core:50068] Updated by Yusuke Endoh about 3 years ago

  • Status changed from Open to Rejected

Also available in: Atom PDF