summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-23 17:38:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-23 17:38:32 +0000
commit65b1dabc8f253ae00f83bdbb4c0b805740fedbdc (patch)
tree490005fc0bab196500f0c75d01b30364c9cd3d1a /io.c
parent2ca89f3917b6b0578e7e02612a6d1dc5e09063df (diff)
downloadruby-65b1dabc8f253ae00f83bdbb4c0b805740fedbdc.tar.gz
ruby-65b1dabc8f253ae00f83bdbb4c0b805740fedbdc.tar.xz
ruby-65b1dabc8f253ae00f83bdbb4c0b805740fedbdc.zip
* io.c (rb_io_external_encoding): should return the encoding of
the file reading. * io.c (rb_io_internal_encoding): should return the encoding of read string. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/io.c b/io.c
index 13179f49e..c6b5ed9a3 100644
--- a/io.c
+++ b/io.c
@@ -5848,6 +5848,9 @@ rb_io_external_encoding(VALUE io)
rb_io_t *fptr;
GetOpenFile(io, fptr);
+ if (fptr->enc2) {
+ return rb_enc_from_encoding(fptr->enc2);
+ }
if (!fptr->enc && fptr->fd == 0) {
fptr->enc = rb_default_external_encoding();
}
@@ -5869,7 +5872,7 @@ rb_io_internal_encoding(VALUE io)
GetOpenFile(io, fptr);
if (!fptr->enc2) return Qnil;
- return rb_enc_from_encoding(fptr->enc2);
+ return rb_enc_from_encoding(fptr->enc);
}
static VALUE