#
+# Copyright (C) 2016 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
# Copyright (C) 2002-2016, International Business Machines Corporation and others.
# All Rights Reserved.
#
# file: char.txt
#
-# ICU Character Break Rules, also known as Grapheme Cluster Boundaries
-# See Unicode Standard Annex #29.
-# These rules are based on UAX #29 Revision 28 (Draft 7) for Unicode Version 9.0
-#
+# ICU Character Break Rules
+# These rules are based on the Extended Grapheme Cluster rules from
+# Unicode UAX #29 Revision 34 for Unicode Version 12.0
+
+!!quoted_literals_only;
#
# Character Class Definitions.
#
$CR = [\p{Grapheme_Cluster_Break = CR}];
$LF = [\p{Grapheme_Cluster_Break = LF}];
-$Control = [[\p{Grapheme_Cluster_Break = Control}]-[:Block=Tags:]];
-$Extend = [[\p{Grapheme_Cluster_Break = Extend}][:Block=Tags:]];
-$ZWJ = [\u200D];
+$Control = [[\p{Grapheme_Cluster_Break = Control}]];
+$Extend = [[\p{Grapheme_Cluster_Break = Extend}]];
+$ZWJ = [\p{Grapheme_Cluster_Break = ZWJ}];
$Regional_Indicator = [\p{Grapheme_Cluster_Break = Regional_Indicator}];
-# TODO: Restore if the Prepend set becomes non-empty again: $Prepend = [\p{Grapheme_Cluster_Break = Prepend}];
+$Prepend = [\p{Grapheme_Cluster_Break = Prepend}];
$SpacingMark = [\p{Grapheme_Cluster_Break = SpacingMark}];
#
# Emoji defintions
-# Apple $EmojiForMods becomes $E_Base here
-$E_Base = [\u261D\u26F9\u270A-\u270D\U0001F385\U0001F3C2-\U0001F3C4\U0001F3C7\U0001F3CA-\U0001F3CC\U0001F442-\U0001F443\U0001F446-\U0001F450\U0001F466-\U0001F478\U0001F47C\U0001F481-\U0001F483\U0001F485-\U0001F487\U0001F4AA\U0001F574-\U0001F575\U0001F57A\U0001F590\U0001F595-\U0001F596\U0001F645-\U0001F647\U0001F64B-\U0001F64F\U0001F6A3\U0001F6B4-\U0001F6B6\U0001F6C0\U0001F6CC\U0001F918-\U0001F91E\U0001F926\U0001F930\U0001F933-\U0001F939\U0001F93C-\U0001F93E];
-# Apple $EmojiMods becomes $E_Modifier here (same set)
-$E_Modifier = [\U0001F3FB-\U0001F3FF];
-# Apple $EmojiForSeqs becomes $GAZ here (only emoji that follow a ZWJ)
-$GAZ = [\u2640\u2642\u2764\u2695-\u2696\u2708\U0001F308\U0001F33E\U0001F373\U0001F393\U0001F3A4\U0001F3A8\U0001F3EB\U0001F3ED\U0001F466-\U0001F469\U0001F48B\U0001F4BB-\U0001F4BC\U0001F527\U0001F52C\U0001F5E8\U0001F680\U0001F692];
+$Extended_Pict = [:ExtPict:];
+
+# The following classes are no longer needed for ICU rules but may
+# still be needed for WebKit rules in charClasses.txt
+# The first is still valid using the Unicode 11 properties:
+# $EmojiNRK = [[\p{Emoji}] - [\p{Grapheme_Cluster_Break = Regional_Indicator}*\u00230-9©®™〰〽]];
+# The other two are no longer valid because no characters have GCB=EB or GCB=EBG anymore:
+# $E_Base = [[\p{Grapheme_Cluster_Break = EB}];
+# $E_Base_GAZ = [\p{Grapheme_Cluster_Break = EBG}];
+# They must be replaced with updated versions as follows
+# $E_Base = [:EBase:];
+# $E_Base_GAZ = [\U000026F9\U0001F466-\U0001F469\U0001F91D\U0001F9D1]; # EBase that also occur after ZWJ in emoji-zwj-sequences
## -------------------------------------------------
!!chain;
!!lookAheadHardBreak;
-!!forward;
$CR $LF;
# GB 9
[^$Control $CR $LF] ($Extend | $ZWJ);
-# GB 9a (only for extended grapheme clusters)
+# GB 9a
[^$Control $CR $LF] $SpacingMark;
-# GB 9b Restore if the Prepend set becomes non-empty again:
-# $Prepend [^$Control $CR $LF];
-
-# GB 10 Do not break within emoji modifier sequences or emoji zwj sequences.
-($E_Base | $GAZ) $Extend* $E_Modifier;
+# GB 9b
+$Prepend [^$Control $CR $LF];
-# GB 11
-$ZWJ $GAZ;
+# GB 11 Do not break within emoji modifier sequences or emoji zwj sequences.
+$Extended_Pict $Extend* $ZWJ $Extended_Pict;
# GB 12-13. Keep pairs of regional indicators together
# Note that hard break '/' rule triggers only if there are three or more initial RIs,
-^$Regional_Indicator $Regional_Indicator / $Regional_Indicator;
-^$Regional_Indicator $Regional_Indicator;
+^$Prepend* $Regional_Indicator $Regional_Indicator / $Regional_Indicator;
+^$Prepend* $Regional_Indicator $Regional_Indicator;
-## -------------------------------------------------
-
-!!reverse;
-$LF $CR;
-($L | $V | $LV | $LVT) $L;
-($V | $T) ($LV | $V);
-$T ($LVT | $T);
-
-# GB 9
-($Extend | $ZWJ) [^$Control $CR $LF]; #note that this will chain into Regional_Indicator when needed.
-
-# GB 9a
-$SpacingMark [^$Control $CR $LF];
-
-# GB 9b Restore if the Prepend set becomes non-empty again:
-# [^$Control $CR $LF] $Prepend;
-
-# GB 10
-$E_Modifier $Extend* ($E_Base | $GAZ);
-
-# GB 11 Don't break between ZWJ and Glue_After_ZWJ
-$GAZ $ZWJ;
-
-# GB 12-13. Going backwards, we must scan through any number of regional indicators as pairs.
-#
-[{bof} $Extend $ZWJ $SpacingMark] $Regional_Indicator $Regional_Indicator / ($Regional_Indicator $Regional_Indicator)+ [{eof}[^$Regional_Indicator]];
-[{bof} $Extend $ZWJ $SpacingMark] $Regional_Indicator / ($Regional_Indicator $Regional_Indicator)+ [{eof}[^$Regional_Indicator]];
-$Regional_Indicator $Regional_Indicator;
-
-## -------------------------------------------------
-
-!!safe_reverse;
-$Regional_Indicator $Regional_Indicator;
-($Extend | $ZWJ)+ .;
-
-## -------------------------------------------------
+# GB 999 Match a single code point if no other rule applies.
+.;
-!!safe_forward;
-$Regional_Indicator $Regional_Indicator;
-($Extend | $ZWJ)+ .;