mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
Regexp supports Unicoe 9.0.0's \X
* meta character \X matches Unicode 9.0.0 characters with some workarounds for UTR #51 Unicode Emoji, Version 4.0 emoji zwj sequences. [Feature #12831] [ruby-core:77586] The term "character" can have many meanings bytes, codepoints, combined characters, and so on. "grapheme cluster" is highest one of such words, which means user-perceived characters. Unicode Standard Annex #29 UNICODE TEXT SEGMENTATION specifies how to handle grapheme clusters (extended grapheme cluster). But some specs aren't updated to current situation because Unicode Emoji is rapidly extended without well definition. It breaks the precondition of UTR#29 "Grapheme cluster boundaries can be easily tested by looking at immediately adjacent characters". (the sentence will be removed in the next version) Though some of its detail are described in Unicode Technical Report #51 UNICODE EMOJI but it is not merged into UTR#29 yet. http://unicode.org/reports/tr29/ http://unicode.org/reports/tr51/ http://unicode.org/Public/emoji/4.0/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e680bfb1ab
commit
c11e648799
8 changed files with 4210 additions and 2254 deletions
|
@ -900,6 +900,27 @@ class TestRegexp < Test::Unit::TestCase
|
|||
assert_no_match(/[[:ascii:]]/, "\x80\xFF")
|
||||
end
|
||||
|
||||
def test_cclass_R
|
||||
assert_match /\A\R\z/, "\r"
|
||||
assert_match /\A\R\z/, "\n"
|
||||
assert_match /\A\R\z/, "\r\n"
|
||||
end
|
||||
|
||||
def test_cclass_X
|
||||
assert_match /\A\X\z/, "\u{20 200d}"
|
||||
assert_match /\A\X\z/, "\u{600 600}"
|
||||
assert_match /\A\X\z/, "\u{600 20}"
|
||||
assert_match /\A\X\z/, "\u{261d 1F3FB}"
|
||||
assert_match /\A\X\z/, "\u{1f600}"
|
||||
assert_match /\A\X\z/, "\u{20 308}"
|
||||
assert_match /\A\X\X\z/, "\u{a 308}"
|
||||
assert_match /\A\X\X\z/, "\u{d 308}"
|
||||
assert_match /\A\X\z/, "\u{1F477 1F3FF 200D 2640 FE0F}"
|
||||
assert_match /\A\X\z/, "\u{1F468 200D 1F393}"
|
||||
assert_match /\A\X\z/, "\u{1F46F 200D 2642 FE0F}"
|
||||
assert_match /\A\X\z/, "\u{1f469 200d 2764 fe0f 200d 1f469}"
|
||||
end
|
||||
|
||||
def test_backward
|
||||
assert_equal(3, "foobar".rindex(/b.r/i))
|
||||
assert_equal(nil, "foovar".rindex(/b.r/i))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue