This project is closed and read-only.
Actions
Backport #4952
closedInteger#chr(Encoding::*) behaves inconsistently with negative or large values
Backport #4952:
Integer#chr(Encoding::*) behaves inconsistently with negative or large values
Status:
Rejected
Assignee:
-
Description
These seem like they should all be raising RangeError; and appear to indicate that values are overflowing/being cast improperly:
ruby-1.9.2-p180 :001 > -1.chr(Encoding::UTF_8)
=> "\xFF"
ruby-1.9.2-p180 :002 > -2.chr(Encoding::UTF_8)
=> "\xFE"
ruby-1.9.2-p180 :006 > -1.chr(Encoding::UTF_16LE)
=> "\uD7BF\xFF\xDF"
ruby-1.9.2-p180 :007 > -2.chr(Encoding::UTF_16LE)
=> "\uD7BF\xFE\xDF"
ruby-1.9.2-p180 :008 > -1234.chr(Encoding::UTF_16LE)
=> "\uD7BE\x2E\xDF"
ruby-1.9.2-p180 :009 > -1.chr(Encoding::EUC_JP)
ArgumentError: invalid codepoint 0xffffffff in EUC-JP
Examples that are inconsistent:
Examples that seem to be fine:
Actions