mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
fc1bf16696
commit
71de56621e
2 changed files with 3 additions and 1 deletions
2
string.c
2
string.c
|
@ -8093,7 +8093,7 @@ rb_str_enumerate_grapheme_clusters(VALUE str, int wantarray)
|
||||||
VALUE MAYBE_UNUSED(ary);
|
VALUE MAYBE_UNUSED(ary);
|
||||||
|
|
||||||
if (!unicode_p) {
|
if (!unicode_p) {
|
||||||
return rb_str_enumerate_codepoints(str, wantarray);
|
return rb_str_enumerate_chars(str, wantarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* synchronize */
|
/* synchronize */
|
||||||
|
|
|
@ -903,6 +903,7 @@ CODE
|
||||||
|
|
||||||
assert_equal ["\u000A", "\u0308"], "\u{a 308}".each_grapheme_cluster.to_a
|
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 ["\u000D", "\u0308"], "\u{d 308}".each_grapheme_cluster.to_a
|
||||||
|
assert_equal ["a", "b", "c"], "abc".b.each_grapheme_cluster.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_grapheme_clusters
|
def test_grapheme_clusters
|
||||||
|
@ -923,6 +924,7 @@ CODE
|
||||||
|
|
||||||
assert_equal ["\u000A", "\u0308"], "\u{a 308}".grapheme_clusters
|
assert_equal ["\u000A", "\u0308"], "\u{a 308}".grapheme_clusters
|
||||||
assert_equal ["\u000D", "\u0308"], "\u{d 308}".grapheme_clusters
|
assert_equal ["\u000D", "\u0308"], "\u{d 308}".grapheme_clusters
|
||||||
|
assert_equal ["a", "b", "c"], "abc".b.grapheme_clusters
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_each_line
|
def test_each_line
|
||||||
|
|
Loading…
Add table
Reference in a new issue