summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-03 01:47:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-03 01:47:19 +0000
commit71de56621ec4643bdfee102f56a153260bb97998 (patch)
treebbcd8e099871aada7025d3127d0df128882cf9bd
parentfc1bf166964bdd5ea6c5fdac58a6f1e7e5b17afe (diff)
string.c: fix for non-Unicode encodings
* string.c (rb_str_enumerate_grapheme_clusters): should enumerate chars for non-Unicode encodings. [Feature #13780] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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 45a4d0e00b5..518fcb9e0b4 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 fb1cfdf68e2..eab0c7cdd83 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