From f4b913484295f4e44d21098ae98680d39c8d948f Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 12 May 2017 11:49:05 +0000 Subject: [PATCH] Encoding.default_internal should affect ENV on Windows like other platforms * hash.c (env_str_transcode): call rb_external_str_with_enc() if default_internal is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hash.c b/hash.c index 3d16b4da9b..60c491f14e 100644 --- a/hash.c +++ b/hash.c @@ -3070,8 +3070,15 @@ extern char **environ; static VALUE env_str_transcode(VALUE str, rb_encoding *enc) { - return rb_str_conv_enc_opts(str, NULL, enc, - ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE, Qnil); + rb_encoding *internal = rb_default_internal_encoding(); + if (!internal) { + return rb_str_conv_enc_opts(str, NULL, enc, + ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE, + Qnil); + } + else { + return rb_external_str_with_enc(str, rb_utf8_encoding()); + } } #endif