diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-08 19:19:22 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-08 19:19:22 +0000 |
commit | ebacc098943aab2e1d5e743f829f880621ea9833 (patch) | |
tree | 3dd9d874d09002458b93a741f9616c653616abcc /ext | |
parent | 117fec74396341a72956bb0e3c5ed8c87614f7e5 (diff) |
merge revision(s) 53435: [Backport #11945]
* ext/stringio/stringio.c (strio_binmode): implement to set encoding
* test/stringio/test_stringio.rb (test_binmode): new test
[ruby-core:72699] [Bug #11945]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@54042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-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 cca408fcb5..ecd7b07203 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 |