summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--string.c2
-rw-r--r--test/ruby/test_string.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/string.c b/string.c
index 45a4d0e00b..518fcb9e0b 100644
--- a/string.c
+++ b/string.c
@@ -8093,7 +8093,7 @@ rb_str_enumerate_grapheme_clusters(VALUE str, int wantarray)
VALUE MAYBE_UNUSED(ary);
if (!unicode_p) {
- return rb_str_enumerate_codepoints(str, wantarray);
+ return rb_str_enumerate_chars(str, wantarray);
}
/* synchronize */
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index fb1cfdf68e..eab0c7cdd8 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -903,6 +903,7 @@ CODE
assert_equal ["\u000A", "\u0308"], "\u{a 308}".each_grapheme_cluster.to_a
assert_equal ["\u000D", "\u0308"], "\u{d 308}".each_grapheme_cluster.to_a
+ assert_equal ["a", "b", "c"], "abc".b.each_grapheme_cluster.to_a
end
def test_grapheme_clusters
@@ -923,6 +924,7 @@ CODE
assert_equal ["\u000A", "\u0308"], "\u{a 308}".grapheme_clusters
assert_equal ["\u000D", "\u0308"], "\u{d 308}".grapheme_clusters
+ assert_equal ["a", "b", "c"], "abc".b.grapheme_clusters
end
def test_each_line