From ec69dddc0d7b0dbaf92ef70bc7b50c7003db0a8e Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 18 Dec 2007 09:14:46 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ string.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 328f1ba021..73001cd73a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Dec 18 18:09:15 2007 Yukihiro Matsumoto + + * string.c (rb_str_splice): propagate encoding. + + * string.c (rb_str_subpat_set): ditto. + Tue Dec 18 17:27:12 2007 Yukihiro Matsumoto * object.c (rb_obj_freeze): preserve frozen state of immediate 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