diff options
Diffstat (limited to 'ext/stringio/stringio.c')
-rw-r--r-- | ext/stringio/stringio.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 55563c3a69..ca99fc72af 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -497,7 +497,17 @@ strio_set_lineno(VALUE self, VALUE lineno) return lineno; } -#define strio_binmode strio_self +static VALUE +strio_binmode(VALUE self) +{ + struct StringIO *ptr = StringIO(self); + rb_encoding *enc = rb_ascii8bit_encoding(); + + if (WRITABLE(self)) { + rb_enc_associate(ptr->string, enc); + } + return self; +} #define strio_fcntl strio_unimpl |