зеркало из https://github.com/github/ruby.git
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2fa316715f
Коммит
7f0d337be7
|
@ -0,0 +1,12 @@
|
|||
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?
|
||||
}
|
2
hash.c
2
hash.c
|
@ -3360,7 +3360,7 @@ env_enc_str_new(const char *ptr, long len, rb_encoding *enc)
|
|||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче