aboutsummaryrefslogtreecommitdiffstats
path: root/transcode.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-17 09:46:30 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-17 09:46:30 +0000
commit4df965f4ed21353b6e0c89ac8286c64c6266ec04 (patch)
tree4b093162914c137315602548313be9d72cbac84d /transcode.c
parentf4d7a34c01256591004bc477c683868ef748f3bd (diff)
downloadruby-4df965f4ed21353b6e0c89ac8286c64c6266ec04.tar.gz
* file.c (rb_str_encode_ospath): when the encoding of the parameter
is ASCII-8BIT, should recognize as filesystem encoding, and convert to UTF-8 on Windows. * file.c (realpath_rec): should convert to ospath encoding before calling lstat(). * file.c (rb_realpath_internal): resolved string should take over the encoding of base string. * transcode.c (rb_str_encode): should return new string always. fixed #3444. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/transcode.c b/transcode.c
index adc72a19d7..dadb57b90d 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2805,7 +2805,12 @@ rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
int encidx = str_transcode0(argc, argv, &newstr, ecflags, ecopts);
if (encidx < 0) return rb_str_dup(str);
- RBASIC(newstr)->klass = rb_obj_class(str);
+ if (newstr == str) {
+ newstr = rb_str_dup(str);
+ }
+ else {
+ RBASIC(newstr)->klass = rb_obj_class(str);
+ }
return str_encode_associate(newstr, encidx);
}