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
This commit is contained in:
nobu 2017-09-03 01:47:19 +00:00
Родитель fc1bf16696
Коммит 71de56621e
2 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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