mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* transcode.c (str_encode_bang, encoded_dup): if nothing was
transcoded, just set encoding but leave coderange unchanged as forcee_encoding. [ruby-core:43557][Bug #6190] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7cbff3b9dd
commit
2b84626193
3 changed files with 20 additions and 0 deletions
|
@ -2785,6 +2785,10 @@ str_encode_bang(int argc, VALUE *argv, VALUE str)
|
|||
encidx = str_transcode(argc, argv, &newstr);
|
||||
|
||||
if (encidx < 0) return str;
|
||||
if (newstr == str) {
|
||||
rb_enc_associate_index(str, encidx);
|
||||
return str;
|
||||
}
|
||||
rb_str_shared_replace(str, newstr);
|
||||
return str_encode_associate(str, encidx);
|
||||
}
|
||||
|
@ -2871,6 +2875,8 @@ encoded_dup(VALUE newstr, VALUE str, int encidx)
|
|||
if (encidx < 0) return rb_str_dup(str);
|
||||
if (newstr == str) {
|
||||
newstr = rb_str_dup(str);
|
||||
rb_enc_associate_index(newstr, encidx);
|
||||
return newstr;
|
||||
}
|
||||
else {
|
||||
RBASIC(newstr)->klass = rb_obj_class(str);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue