aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/io.c b/io.c
index dbe39cd95b..6fd9f54d10 100644
--- a/io.c
+++ b/io.c
@@ -2895,9 +2895,14 @@ rb_io_each_codepoint(VALUE io)
rb_enc_name(fptr->encs.enc));
}
n = MBCLEN_CHARFOUND_LEN(r);
- c = rb_enc_codepoint(fptr->cbuf+fptr->cbuf_off,
- fptr->cbuf+fptr->cbuf_off+fptr->cbuf_len,
- fptr->encs.enc);
+ if (fptr->encs.enc) {
+ c = rb_enc_codepoint(fptr->cbuf+fptr->cbuf_off,
+ fptr->cbuf+fptr->cbuf_off+fptr->cbuf_len,
+ fptr->encs.enc);
+ }
+ else {
+ c = (unsigned char)fptr->cbuf[fptr->cbuf_off];
+ }
fptr->cbuf_off += n;
fptr->cbuf_len -= n;
rb_yield(UINT2NUM(c));