зеркало из https://github.com/github/ruby.git
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:
Родитель
fc1bf16696
Коммит
71de56621e
2
string.c
2
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 */
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче