diff options
author | Jean byroot Boussier <[email protected]> | 2024-04-17 03:29:09 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-04-17 01:29:18 +0000 |
commit | 75154dec73e1329693866e3a88cb9febb7635417 () | |
tree | de4ed05b715f2ce51f322cf2fce13eacaa019b46 /ext/stringio/stringio.c | |
parent | f34409bf8782481deabec6c577abd66373134af9 (diff) |
[ruby/stringio] strio_read: preserve buffer encoding on partial
reads (https://.com/ruby/stringio/pull/95) [[Bug #20418]](https://bugs.ruby-lang.org/issues/20418) Ruby IO#read preserves the encoding on partial read, but change it when reading the whole IO from commit https://.com/ruby/ruby/commit/0ca7036682da: > * io.c (read_all): should associate default external encoding. > * io.c (io_read): should NOT associate default external encoding. https://.com/ruby/stringio/commit/073172da31 Co-authored-by: Jean Boussier <[email protected]>
-rw-r--r-- | ext/stringio/stringio.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -1623,10 +1623,9 @@ strio_read(int argc, VALUE *argv, VALUE self) if (len > rest) len = rest; rb_str_resize(str, len); MEMCPY(RSTRING_PTR(str), RSTRING_PTR(ptr->string) + ptr->pos, char, len); - if (binary) - rb_enc_associate(str, rb_ascii8bit_encoding()); - else rb_enc_copy(str, ptr->string); } ptr->pos += RSTRING_LEN(str); return str; |