aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/io.c b/io.c
index 472c161751..1833835cc9 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;