summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-09-01 06:59:31 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-09-01 07:00:56 +0900
commit41d0b343e6701da167ed26ccf085ea1cf86d8588 (patch)
tree598b6090e3bcab8f710c532911053f481257d1bc /src/string.c
parent7ffffbfe01eaa9fe73d987582ee3cb406b76e6b4 (diff)
downloadmruby-41d0b343e6701da167ed26ccf085ea1cf86d8588.tar.gz
mruby-41d0b343e6701da167ed26ccf085ea1cf86d8588.zip
string.c: need to adjust index for UTF-8.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/string.c b/src/string.c
index 21be97db6..1a8b01c66 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2868,13 +2868,13 @@ sub_replace(mrb_state *mrb, mrb_value self)
mrb_str_cat(mrb, result, "\\", 1);
break;
case '`':
- mrb_str_cat(mrb, result, RSTRING_PTR(self), found);
+ mrb_str_cat(mrb, result, RSTRING_PTR(self), chars2bytes(self, 0, found));
break;
case '&': case '0':
mrb_str_cat(mrb, result, match, mlen);
break;
case '\'':
- offset = found + mlen;
+ offset = chars2bytes(self, 0, found) + mlen;
if (RSTRING_LEN(self) > offset) {
mrb_str_cat(mrb, result, RSTRING_PTR(self)+offset, RSTRING_LEN(self)-offset);
}