ruby-changes:52648
From: nobu <ko1@a...>
Date: Thu, 27 Sep 2018 02:24:06 +0900 (JST)
Subject: [ruby-changes:52648] nobu:r64860 (trunk): fallback env encoding to ASCII-8BIT
nobu 2018-09-27 02:24:00 +0900 (Thu, 27 Sep 2018) New Revision: 64860 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64860 Log: fallback env encoding to ASCII-8BIT * hash.c (env_enc_str_new): as no locale/filesystem encoding is available in miniruby on Windows, fallback the encoding to ASCII-8BIT so it is valid encoding when the conversion failed. [ruby-core:89177] [Bug #15164] Added files: trunk/bootstraptest/test_env.rb Modified files: trunk/hash.c Index: hash.c =================================================================== --- hash.c (revision 64859) +++ hash.c (revision 64860) @@ -3360,7 +3360,7 @@ env_enc_str_new(const char *ptr, long le https://github.com/ruby/ruby/blob/trunk/hash.c#L3360 rb_encoding *utf8 = rb_utf8_encoding(); VALUE str = rb_enc_str_new(NULL, 0, (internal ? internal : enc)); if (NIL_P(rb_str_cat_conv_enc_opts(str, 0, ptr, len, utf8, ecflags, Qnil))) { - rb_str_initialize(str, ptr, len, utf8); + rb_str_initialize(str, ptr, len, NULL); } #else VALUE str = rb_external_str_new_with_enc(ptr, len, enc); Index: bootstraptest/test_env.rb =================================================================== --- bootstraptest/test_env.rb (nonexistent) +++ bootstraptest/test_env.rb (revision 64860) @@ -0,0 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_env.rb#L1 +assert_equal "true", %q{ + ENV["ENVTEST"] = "\u{e9 3042 d76c}" + env = ENV["ENVTEST"] + env.valid_encoding? +} + +# different encoding is used for PATH +assert_equal "true", %q{ + ENV["PATH"] = "\u{e9 3042 d76c}" + env = ENV["PATH"] + env.valid_encoding? +} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/