diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-07-19 16:08:03 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-07-20 14:59:19 +0900 |
commit | ddb2acbba60302201f01175f019d8ecd99934add (patch) | |
tree | 396d515ee394573cfd4672bb79ddc9b7704b33af /ext | |
parent | c62aff16325c6b170f437f7ebe97c09387464ada (diff) |
[ruby/stringio] No compatibility check in US-ASCII case
https://github.com/ruby/stringio/commit/59df1c8293
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3334
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; |