From 41d0b343e6701da167ed26ccf085ea1cf86d8588 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 1 Sep 2021 06:59:31 +0900 Subject: string.c: need to adjust index for UTF-8. --- src/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/string.c') 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); } -- cgit v1.2.3