]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | # |
2 | # Copyright (C) 2016 and later: Unicode, Inc. and others. | |
3 | # License & terms of use: http://www.unicode.org/copyright.html | |
2ca993e8 A |
4 | # Copyright (C) 2002-2016, International Business Machines Corporation and others. |
5 | # All Rights Reserved. | |
6 | # | |
7 | # file: char.txt | |
8 | # | |
9 | # ICU Character Break Rules, also known as Grapheme Cluster Boundaries | |
10 | # See Unicode Standard Annex #29. | |
f3c0d7a5 A |
11 | # These rules are based on UAX #29 Revision 29 for Unicode Version 9.0 |
12 | # Plus revisions to rule GB 11 from http://unicode.org/cldr/trac/ticket/10088 | |
13 | # Plus additional characters introduces with Emoji 5, http://www.unicode.org/reports/tr51/proposed.html | |
2ca993e8 A |
14 | |
15 | # | |
16 | # Character Class Definitions. | |
17 | # | |
18 | $CR = [\p{Grapheme_Cluster_Break = CR}]; | |
19 | $LF = [\p{Grapheme_Cluster_Break = LF}]; | |
f3c0d7a5 A |
20 | $Control = [[\p{Grapheme_Cluster_Break = Control}]]; |
21 | $Extend = [[\p{Grapheme_Cluster_Break = Extend}]]; | |
22 | $ZWJ = [\p{Grapheme_Cluster_Break = ZWJ}]; | |
2ca993e8 | 23 | $Regional_Indicator = [\p{Grapheme_Cluster_Break = Regional_Indicator}]; |
f3c0d7a5 | 24 | $Prepend = [\p{Grapheme_Cluster_Break = Prepend}]; |
2ca993e8 A |
25 | $SpacingMark = [\p{Grapheme_Cluster_Break = SpacingMark}]; |
26 | ||
27 | # | |
28 | # Korean Syllable Definitions | |
29 | # | |
30 | $L = [\p{Grapheme_Cluster_Break = L}]; | |
31 | $V = [\p{Grapheme_Cluster_Break = V}]; | |
32 | $T = [\p{Grapheme_Cluster_Break = T}]; | |
33 | ||
34 | $LV = [\p{Grapheme_Cluster_Break = LV}]; | |
35 | $LVT = [\p{Grapheme_Cluster_Break = LVT}]; | |
36 | ||
37 | # Emoji defintions | |
38 | ||
f3c0d7a5 A |
39 | $E_Base = [[\p{Grapheme_Cluster_Break = EB}] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C]; |
40 | $E_Modifier = [\p{Grapheme_Cluster_Break = EM}]; | |
41 | ||
42 | # Data for Extended Pictographic scraped from CLDR common/properties/ExtendedPictographic.txt, r13267 | |
43 | $Extended_Pict = [\U0001F774-\U0001F77F\U00002700-\U00002701\U00002703-\U00002704\U0000270E\U00002710-\U00002711\U00002765-\U00002767\U0001F030-\U0001F093\U0001F094-\U0001F09F\U0001F10D-\U0001F10F\U0001F12F\U0001F16C-\U0001F16F\U0001F1AD-\U0001F1E5\U0001F260-\U0001F265\U0001F203-\U0001F20F\U0001F23C-\U0001F23F\U0001F249-\U0001F24F\U0001F252-\U0001F25F\U0001F266-\U0001F2FF\U0001F7D5-\U0001F7FF\U0001F000-\U0001F003\U0001F005-\U0001F02B\U0001F02C-\U0001F02F\U0001F322-\U0001F323\U0001F394-\U0001F395\U0001F398\U0001F39C-\U0001F39D\U0001F3F1-\U0001F3F2\U0001F3F6\U0001F4FE\U0001F53E-\U0001F548\U0001F54F\U0001F568-\U0001F56E\U0001F571-\U0001F572\U0001F57B-\U0001F586\U0001F588-\U0001F589\U0001F58E-\U0001F58F\U0001F591-\U0001F594\U0001F597-\U0001F5A3\U0001F5A6-\U0001F5A7\U0001F5A9-\U0001F5B0\U0001F5B3-\U0001F5BB\U0001F5BD-\U0001F5C1\U0001F5C5-\U0001F5D0\U0001F5D4-\U0001F5DB\U0001F5DF-\U0001F5E0\U0001F5E2\U0001F5E4-\U0001F5E7\U0001F5E9-\U0001F5EE\U0001F5F0-\U0001F5F2\U0001F5F4-\U0001F5F9\U00002605\U00002607-\U0000260D\U0000260F-\U00002610\U00002612\U00002616-\U00002617\U00002619-\U0000261C\U0000261E-\U0000261F\U00002621\U00002624-\U00002625\U00002627-\U00002629\U0000262B-\U0000262D\U00002630-\U00002637\U0000263B-\U00002647\U00002654-\U0000265F\U00002661-\U00002662\U00002664\U00002667\U00002669-\U0000267A\U0000267C-\U0000267E\U00002680-\U00002691\U00002695\U00002698\U0000269A\U0000269D-\U0000269F\U000026A2-\U000026A9\U000026AC-\U000026AF\U000026B2-\U000026BC\U000026BF-\U000026C3\U000026C6-\U000026C7\U000026C9-\U000026CD\U000026D0\U000026D2\U000026D5-\U000026E8\U000026EB-\U000026EF\U000026F6\U000026FB-\U000026FC\U000026FE-\U000026FF\U00002388\U0001FA00-\U0001FFFD\U0001F0A0-\U0001F0AE\U0001F0B1-\U0001F0BF\U0001F0C1-\U0001F0CF\U0001F0D1-\U0001F0F5\U0001F0AF-\U0001F0B0\U0001F0C0\U0001F0D0\U0001F0F6-\U0001F0FF\U0001F80C-\U0001F80F\U0001F848-\U0001F84F\U0001F85A-\U0001F85F\U0001F888-\U0001F88F\U0001F8AE-\U0001F8FF\U0001F900-\U0001F90B\U0001F91F\U0001F928-\U0001F92F\U0001F931-\U0001F932\U0001F94C\U0001F95F-\U0001F96B\U0001F992-\U0001F997\U0001F9D0-\U0001F9E6\U0001F90C-\U0001F90F\U0001F93F\U0001F94D-\U0001F94F\U0001F96C-\U0001F97F\U0001F998-\U0001F9BF\U0001F9C1-\U0001F9CF\U0001F9E7-\U0001F9FF\U0001F6C6-\U0001F6CA\U0001F6D3-\U0001F6D4\U0001F6E6-\U0001F6E8\U0001F6EA\U0001F6F1-\U0001F6F2\U0001F6F7-\U0001F6F8\U0001F6D5-\U0001F6DF\U0001F6ED-\U0001F6EF\U0001F6F9-\U0001F6FF]; | |
44 | $E_Base_GAZ = [\p{Grapheme_Cluster_Break = EBG}]; | |
45 | $EmojiNRK = [[\p{Emoji}] - [\p{Grapheme_Cluster_Break = Regional_Indicator}*\u00230-9©®™〰〽]]; | |
2ca993e8 A |
46 | |
47 | ## ------------------------------------------------- | |
48 | !!chain; | |
49 | !!lookAheadHardBreak; | |
50 | !!forward; | |
51 | ||
52 | $CR $LF; | |
53 | ||
54 | $L ($L | $V | $LV | $LVT); | |
55 | ($LV | $V) ($V | $T); | |
56 | ($LVT | $T) $T; | |
57 | ||
58 | # GB 9 | |
59 | [^$Control $CR $LF] ($Extend | $ZWJ); | |
60 | ||
61 | # GB 9a (only for extended grapheme clusters) | |
62 | [^$Control $CR $LF] $SpacingMark; | |
63 | ||
f3c0d7a5 A |
64 | # GB 9b |
65 | $Prepend [^$Control $CR $LF]; | |
2ca993e8 A |
66 | |
67 | # GB 10 Do not break within emoji modifier sequences or emoji zwj sequences. | |
f3c0d7a5 | 68 | ($E_Base | $E_Base_GAZ) $Extend* $E_Modifier; |
2ca993e8 A |
69 | |
70 | # GB 11 | |
f3c0d7a5 | 71 | ($Extended_Pict | $EmojiNRK) $Extend* $ZWJ ($Extended_Pict | $EmojiNRK); |
2ca993e8 A |
72 | |
73 | # GB 12-13. Keep pairs of regional indicators together | |
74 | # Note that hard break '/' rule triggers only if there are three or more initial RIs, | |
75 | ||
f3c0d7a5 A |
76 | ^$Prepend* $Regional_Indicator $Regional_Indicator / $Regional_Indicator; |
77 | ^$Prepend* $Regional_Indicator $Regional_Indicator; | |
2ca993e8 A |
78 | |
79 | ## ------------------------------------------------- | |
80 | ||
81 | !!reverse; | |
82 | $LF $CR; | |
83 | ($L | $V | $LV | $LVT) $L; | |
84 | ($V | $T) ($LV | $V); | |
85 | $T ($LVT | $T); | |
86 | ||
87 | # GB 9 | |
88 | ($Extend | $ZWJ) [^$Control $CR $LF]; #note that this will chain into Regional_Indicator when needed. | |
89 | ||
90 | # GB 9a | |
91 | $SpacingMark [^$Control $CR $LF]; | |
92 | ||
f3c0d7a5 A |
93 | # GB 9b |
94 | [^$Control $CR $LF] $Prepend; | |
2ca993e8 A |
95 | |
96 | # GB 10 | |
f3c0d7a5 | 97 | $E_Modifier $Extend* ($E_Base | $E_Base_GAZ); |
2ca993e8 A |
98 | |
99 | # GB 11 Don't break between ZWJ and Glue_After_ZWJ | |
f3c0d7a5 | 100 | ($Extended_Pict | $EmojiNRK) $ZWJ $Extend* ($Extended_Pict | $EmojiNRK); |
2ca993e8 A |
101 | |
102 | # GB 12-13. Going backwards, we must scan through any number of regional indicators as pairs. | |
103 | # | |
104 | [{bof} $Extend $ZWJ $SpacingMark] $Regional_Indicator $Regional_Indicator / ($Regional_Indicator $Regional_Indicator)+ [{eof}[^$Regional_Indicator]]; | |
105 | [{bof} $Extend $ZWJ $SpacingMark] $Regional_Indicator / ($Regional_Indicator $Regional_Indicator)+ [{eof}[^$Regional_Indicator]]; | |
106 | $Regional_Indicator $Regional_Indicator; | |
f3c0d7a5 | 107 | $Regional_Indicator $Prepend; |
2ca993e8 A |
108 | |
109 | ## ------------------------------------------------- | |
110 | ||
111 | !!safe_reverse; | |
112 | $Regional_Indicator $Regional_Indicator; | |
f3c0d7a5 | 113 | ($Extend | $ZWJ | $EmojiNRK | $Extended_Pict)+ .; |
2ca993e8 A |
114 | |
115 | ## ------------------------------------------------- | |
116 | ||
117 | !!safe_forward; | |
118 | $Regional_Indicator $Regional_Indicator; | |
f3c0d7a5 | 119 | ($Extend | $ZWJ | $EmojiNRK | $Extended_Pict)+ .; |