aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--io.c5
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c680ad4910..0b80a3c025 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,12 @@ Mon Dec 24 02:06:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (io_fwrite): wrong encoding destination.
+ * 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.
+
Mon Dec 24 01:46:43 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_s_pipe): allow specifying read-side encoding.
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