diff options
Diffstat (limited to 'ext/io/console/console.c')
-rw-r--r-- | ext/io/console/console.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c index b8b36249b7..f10b1e4a15 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -443,14 +443,12 @@ console_getch(int argc, VALUE *argv, VALUE io) len = 1; do { buf[len++] = (unsigned char)c; - } while ((c >>= CHAR_BIT) && len < sizeof(buf)); + } while ((c >>= CHAR_BIT) && len < (int)sizeof(buf)); return rb_str_new(buf, len); default: len = rb_uv_to_utf8(buf, c); - str = rb_enc_str_new(0, 0, rb_default_external_encoding()); - rb_str_cat_conv_enc_opts(str, 0, buf, len, rb_utf8_encoding(), - 0, Qnil); - return str; + str = rb_utf8_str_new(buf, len); + return rb_str_conv_enc(str, NULL, rb_default_external_encoding()); } #endif } |