summaryrefslogtreecommitdiff
path: root/ext/stringio
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-12 01:47:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-12 01:47:09 +0000
commit6ee82564fac2745e45154938b5b75d9f5ab70b58 (patch)
tree0d8d1c78c9289c1860b5a27350f01ec7f5bed64d /ext/stringio
parent201d0e7e3362f09529f527d2ed525013eda51513 (diff)
stringio.c: encoding at EOF
* ext/stringio/stringio.c (strio_read): should return string with the external encoding, at EOF too. [ruby-core:82349] [Bug #13806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 826da86..032f80a 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -1392,12 +1392,14 @@ strio_read(int argc, VALUE *argv, VALUE self)
case 0:
len = RSTRING_LEN(ptr->string);
if (len <= ptr->pos) {
+ rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr);
if (NIL_P(str)) {
str = rb_str_new(0, 0);
}
else {
rb_str_resize(str, 0);
}
+ rb_enc_associate(str, enc);
return str;
}
else {