From dc5f9c4b88826cc4f0042abf74dc368a6c3c783b Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 5 Sep 2008 22:26:39 +0000 Subject: * io.c (rb_io_extract_modeenc): raise an error for ASCII incompatible encoding without binmode. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index 472c16175..1833835cc 100644 --- a/io.c +++ b/io.c @@ -3898,6 +3898,9 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE opthash, if ((fmode & FMODE_BINMODE) && (fmode & FMODE_TEXTMODE)) rb_raise(rb_eArgError, "both textmode and binmode specified"); + if (enc && !rb_enc_asciicompat(enc) && !(fmode & FMODE_BINMODE)) + rb_raise(rb_eArgError, "ASCII incompatible encoding needs binmode"); + *vmode_p = vmode; *oflags_p = oflags; -- cgit