diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-06-09 10:11:06 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-06-09 10:11:06 +0900 |
| commit | dd8903fed72c2d06fe7a0ca6b5ef88e9140be451 (patch) | |
| tree | 3c3d58ddb5a6e9bff2f7856d5348f0a5d455d925 /string.c | |
| parent | 6ea9cd49099b83aebbab9463e3432cb03a4b6ba4 (diff) | |
[Bug #20566] Mention out-of-range argument cases in `String#<<`
Also [Bug #18973].
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -3595,6 +3595,22 @@ rb_str_concat_multi(int argc, VALUE *argv, VALUE str) * s = 'foo' * s << 33 # => "foo!" * + * If that codepoint is not representable in the encoding of + * _string_, RangeError is raised. + * + * s = 'foo' + * s.encoding # => <Encoding:UTF-8> + * s << 0x00110000 # 1114112 out of char range (RangeError) + * s = 'foo'.encode('EUC-JP') + * s << 0x00800080 # invalid codepoint 0x800080 in EUC-JP (RangeError) + * + * If the encoding is US-ASCII and the codepoint is 0..0xff, _string_ + * is automatically promoted to ASCII-8BIT. + * + * s = 'foo'.encode('US-ASCII') + * s << 0xff + * s.encoding # => #<Encoding:BINARY (ASCII-8BIT)> + * * Related: String#concat, which takes multiple arguments. */ VALUE |
