Skip to content

Encoding.compatible? affected by call order #2312

@nirvdrum

Description

@nirvdrum

EncodingService has two lookup tables. One takes an Encoding's index and returns a RubyEncoding. This table is lazily created. A single Encoding may be used by multiple RubyEncodings. One such case is with "GB2312" and "EUC-KR". Whichever gets loaded first will occupy the spot in the table and the other will resolve to that RubyEncoding.

Examples:

$ bin/jruby -e 'p Encoding.compatible?(Encoding.find("GB2312"), Encoding.find("EUC-KR")); p Encoding.compatible?(Encoding.find("EUC-KR"), Encoding.find("GB2312"))'
#<Encoding:EUC-KR>
#<Encoding:EUC-KR>
$ bin/jruby -e 'p Encoding.compatible?(Encoding.find("EUC-KR"), Encoding.find("GB2312")); p Encoding.compatible?(Encoding.find("GB2312"), Encoding.find("EUC-KR"))'
#<Encoding:GB2312>
#<Encoding:GB2312>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions