From: Run Paint Run Run Date: 2009-06-24T06:42:29+09:00 Subject: [ruby-core:23997] [Bug #1681] Integer#chr Should Infer Encoding of Given Codepoint Bug #1681: Integer#chr Should Infer Encoding of Given Codepoint http://redmine.ruby-lang.org/issues/show/1681 Author: Run Paint Run Run Status: Open, Priority: Low Category: M17N ruby -v: ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux] String#ord and Integer#chr are symmetrical operations on ASCII Strings: 'a'.ord.chr #=> "a" But Integer#chr fails to round-trip when the given codepoint is outside the range of ASCII: "\u{2563}".ord.chr #=> RangeError: 9571 out of char range To fix this, the codepoint's encoding needs to be specified: "\u{2563}".ord.chr('utf-8') #=> "���" This seems needlessly verbose given that Ruby already knows that my source encoding is UTF-8. I suggest, then, that, when invoked with no argument, Integer#chr displays the given codepoint w.r.t to the current encoding, raising a RangeError only if the codepoint is out-of-bounds for this inferred encoding. ---------------------------------------- http://redmine.ruby-lang.org