diff --git a/ChangeLog b/ChangeLog index 1051ebde26..6b497d3c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,11 @@ Fri Dec 21 12:16:50 2007 Tanaka Akira * string.c (rb_str_is_ascii_only_p): new method ascii_only?. +Fri Dec 21 12:11:57 2007 Yukihiro Matsumoto + + * io.c (rb_io_mode_enc): set default external encoding if no + encoding specified explicitly. + Fri Dec 21 12:00:34 2007 Tanaka Akira * configure.in: check langinfo.h and locale.h. diff --git a/io.c b/io.c index e07845fb31..89d15cac8d 100644 --- a/io.c +++ b/io.c @@ -3068,6 +3068,9 @@ rb_io_mode_enc(rb_io_t *fptr, const char *mode) } #endif } + else if (!(fptr->mode & FMODE_BINMODE)) { + fptr->enc = rb_default_external_encoding(); + } } struct sysopen_struct { @@ -3188,8 +3191,8 @@ rb_file_open_internal(VALUE io, const char *fname, const char *mode) rb_io_t *fptr; MakeOpenFile(io, fptr); - rb_io_mode_enc(fptr, mode); fptr->mode = rb_io_mode_flags(mode); + rb_io_mode_enc(fptr, mode); fptr->path = strdup(fname); fptr->fd = rb_sysopen(fptr->path, rb_io_mode_modenum(rb_io_flags_mode(fptr->mode)), 0666); io_check_tty(fptr); @@ -3498,10 +3501,10 @@ pipe_open(const char *cmd, int argc, VALUE *argv, const char *mode) port = io_alloc(rb_cIO); MakeOpenFile(port, fptr); - rb_io_mode_enc(fptr, mode); fptr->fd = fd; fptr->stdio_file = fp; fptr->mode = modef | FMODE_SYNC|FMODE_DUPLEX; + rb_io_mode_enc(fptr, mode); fptr->pid = pid; if (0 <= write_fd) {