Bug #5863
closedInteger#chr may return a string with multiple characters
Description
=begin
Is this a bug?
256.chr("SHIFT_JIS").length #=> 2
I think so, as it means that #chr and #ord can't be treated as inverses, and is generally confusing.
If not, the documentation for #chr should be changed, as it implies that the returned string is always a single character.
=end
Updated by naruse (Yui NARUSE) almost 13 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r34236.
John, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
-
numeric.c (rb_enc_uint_char): raise RangeError when added codepoint
is invalid. [Feature #5855] [Bug #5863] [Bug #5864] -
string.c (rb_str_concat): ditto.
-
string.c (rb_str_concat): set encoding as ASCII-8BIT when the string
is US-ASCII and the argument is an integer greater than 127. -
regenc.c (onigenc_mb2_code_to_mbclen): rearrange error code.
-
enc/euc_jp.c (code_to_mbclen): ditto.
-
enc/shift_jis.c (code_to_mbclen): ditto.