From ddb2acbba60302201f01175f019d8ecd99934add Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 19 Jul 2020 16:08:03 +0900 Subject: [ruby/stringio] No compatibility check in US-ASCII case https://github.com/ruby/stringio/commit/59df1c8293 --- ext/stringio/stringio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 9ab8537ac1..d55af518c7 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1429,14 +1429,15 @@ strio_write(VALUE self, VALUE str) long len, olen; rb_encoding *enc, *enc2; rb_encoding *const ascii8bit = rb_ascii8bit_encoding(); + rb_encoding *usascii = 0; if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); enc = get_enc(ptr); enc2 = rb_enc_get(str); - if (enc != enc2 && enc != ascii8bit) { + if (enc != enc2 && enc != ascii8bit && enc != (usascii = rb_usascii_encoding())) { VALUE converted = rb_str_conv_enc(str, enc2, enc); - if (converted == str && enc2 != ascii8bit) { /* conversion failed */ + if (converted == str && enc2 != ascii8bit && enc2 != usascii) { /* conversion failed */ rb_enc_check(rb_enc_from_encoding(enc), str); } str = converted; -- cgit v1.2.3