From 9145aed85ef4458846f6412585f86d1ea0eb150f Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 5 Jan 2016 18:05:25 +0900 Subject: bytes2chars() conversion to fail if target byte offset is not on the character boundary; ref #3067 that means String#index matches first byte of a multi-byte character. this behavior is different from CRuby, but a compromise for mruby which does not have encoding stuffs. --- src/string.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/string.c b/src/string.c index 0d31a304f..a3f337d4b 100644 --- a/src/string.c +++ b/src/string.c @@ -306,17 +306,20 @@ bytes2chars(char *p, mrb_int bi) mrb_int i, b, n; for (b=i=0; b= 0) { pos = bytes2chars(RSTRING_PTR(str), pos); + BYTES_ALIGN_CHECK(pos); return mrb_fixnum_value(pos); } break; -- cgit v1.2.3