summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-17 09:55:46 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-17 09:55:46 +0000
commite557b8821b3d634fe3265dd401699d5e398fc28d (patch)
tree78153dc8bf9bfff453f999ddbec4201bdc129974 /transcode.c
parent6fefc895cacfbd5bed94f5d36cffb88b84cd9d57 (diff)
merge from trunk (r28349)
* 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/branches/ruby_1_9_2@28350 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);
}