From: John Firebaugh Date: 2012-01-08T10:58:00+09:00 Subject: [ruby-core:41973] [ruby-trunk - Bug #5864][Open] Integer#chr raises on some invalid codepoints but returns an invalidly-encoded string for others Issue #5864 has been reported by John Firebaugh. ---------------------------------------- Bug #5864: Integer#chr raises on some invalid codepoints but returns an invalidly-encoded string for others https://bugs.ruby-lang.org/issues/5864 Author: John Firebaugh Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0] =begin Integer#chr raises RangeError on some invalid codepoints, but on others it returns an invalidly-encoded string. 0x0100.chr("EUC-JP") # Raises 0xA1A0.chr("EUC-JP").valid_encoding? #=> false 0x80.chr("SHIFT_JIS").valid_encoding? #=> false 0xA1.chr("EUC-JP") # Raises 0xE0.chr("SHIFT_JIS").valid_encoding? #=> false If this is not a bug, could someone please explain the semantics for when Integer#chr should raise RangeError versus when it should return an invalidly-encoded string? =end -- http://redmine.ruby-lang.org