summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-29 20:01:14 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-01 20:28:44 +0900
commit3e46117d3fb12d1428c97daf9e8d6bce36b90240 (patch)
tree9e8f1beb8c7e64ce4b79814b87b1c968eefd4b81 /file.c
parent842b0008c132dd587f09766a228041afb7fed24f (diff)
Associate the encoding to the found path
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4915
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/file.c b/file.c
index 98b9d50446..626043816f 100644
--- a/file.c
+++ b/file.c
@@ -6369,6 +6369,10 @@ is_explicit_relative(const char *path)
static VALUE
copy_path_class(VALUE path, VALUE orig)
{
+ int encidx = rb_enc_get_index(orig);
+ if (encidx == ENCINDEX_ASCII || encidx == ENCINDEX_US_ASCII)
+ encidx = rb_filesystem_encindex();
+ rb_enc_associate_index(path, encidx);
str_shrink(path);
RBASIC_SET_CLASS(path, rb_obj_class(orig));
OBJ_FREEZE(path);