diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -11573,6 +11573,11 @@ io_encoding_set(rb_io_t *fptr, VALUE v1, VALUE v2, VALUE opt) enc2 = NULL; } } + if (enc2 == rb_ascii8bit_encoding()) { + /* If external is ASCII-8BIT, no transcoding */ + enc = enc2; + enc2 = NULL; + } SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(enc2, ecflags); ecflags = rb_econv_prepare_options(opt, &ecopts, ecflags); } @@ -13393,10 +13398,12 @@ rb_io_internal_encoding(VALUE io) * * See {Encodings}[rdoc-ref:File@Encodings]. * - * Argument +ext_enc+, if given, must be an Encoding object; + * Argument +ext_enc+, if given, must be an Encoding object + * or a String with the encoding name; * it is assigned as the encoding for the stream. * - * Argument +int_enc+, if given, must be an Encoding object; + * Argument +int_enc+, if given, must be an Encoding object + * or a String with the encoding name; * it is assigned as the encoding for the internal string. * * Argument <tt>'ext_enc:int_enc'</tt>, if given, is a string @@ -13404,6 +13411,10 @@ rb_io_internal_encoding(VALUE io) * corresponding Encoding objects are assigned as the external * and internal encodings for the stream. * + * If the external encoding of a string is binary/ASCII-8BIT, + * the internal encoding of the string is set to nil, since no + * transcoding is needed. + * * Optional keyword arguments +enc_opts+ specify * {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options]. * |