mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: fix up r58703
* string.c (rb_external_str_new_with_enc): fix the case of conversion failure. when conversion failed for some reason, just ignores the default internal encoding and returns in the given encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
eafeb506cd
commit
a3960d0a60
1 changed files with 6 additions and 2 deletions
8
string.c
8
string.c
|
@ -1008,8 +1008,12 @@ rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
|
|||
if (!ienc || eenc == ienc) {
|
||||
return rb_tainted_str_new_with_enc(ptr, len, eenc);
|
||||
}
|
||||
str = rb_tainted_str_new_with_enc(NULL, len, ienc);
|
||||
rb_str_cat_conv_enc_opts(str, 0, ptr, len, eenc, 0, Qnil);
|
||||
str = rb_tainted_str_new_with_enc(NULL, 0, ienc);
|
||||
if (NIL_P(rb_str_cat_conv_enc_opts(str, 0, ptr, len, eenc, 0, Qnil))) {
|
||||
STR_SET_LEN(str, 0);
|
||||
rb_enc_associate(str, eenc);
|
||||
rb_str_cat(str, ptr, len);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue