From 5f9748deb7b934d3ba150ea3184cb1006a7dc9fd Mon Sep 17 00:00:00 2001 From: matz Date: Sun, 23 Dec 2007 17:38:32 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@14542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'io.c') diff --git a/io.c b/io.c index 13179f49ed..c6b5ed9a36 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 -- cgit v1.2.3