summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-18 09:14:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-18 09:14:46 +0000
commitec69dddc0d7b0dbaf92ef70bc7b50c7003db0a8e (patch)
treedfca599b50661165e12f8d72ae14d89cd0dbf0ce /string.c
parent2521b33ed74822cb6e81a180bfbcfff3e1683815 (diff)
* string.c (rb_str_splice): propagate encoding.
* string.c (rb_str_subpat_set): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/string.c b/string.c
index fb3a116c57..105fe6a15d 100644
--- a/string.c
+++ b/string.c
@@ -2142,6 +2142,7 @@ rb_str_splice(VALUE str, long beg, long len, VALUE val)
beg = p - RSTRING_PTR(str); /* physical position */
len = e - p; /* physical length */
rb_str_splice_0(str, beg, len, val);
+ rb_enc_associate(str, enc);
}
void
@@ -2155,6 +2156,7 @@ rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
{
VALUE match;
long start, end, len;
+ rb_encoding *enc;
if (rb_reg_search(re, str, 0, 0) < 0) {
rb_raise(rb_eIndexError, "regexp not matched");
@@ -2178,8 +2180,9 @@ rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
end = RMATCH(match)->END(nth);
len = end - start;
StringValue(val);
- rb_enc_check(str, val);
+ enc = rb_enc_check(str, val);
rb_str_splice_0(str, start, len, val);
+ rb_enc_associate(str, enc);
}
static VALUE