|
32 | 32 |
|
33 | 33 | // This implementation is derived from ICU: icu4c/source/extra/scrptrun/scrptrun.cpp |
34 | 34 |
|
| 35 | +inline constexpr UChar32 ZERO_WIDTH_JOINER = 0x200d; |
| 36 | +inline constexpr UChar32 VARIATION_SELECTOR_15 = 0xfe0e; |
| 37 | +inline constexpr UChar32 VARIATION_SELECTOR_16 = 0xfe0f; |
| 38 | + |
35 | 39 | inline bool ScriptIterator::same_script(int32_t p_script_one, int32_t p_script_two) { |
36 | 40 | return p_script_one <= USCRIPT_INHERITED || p_script_two <= USCRIPT_INHERITED || p_script_one == p_script_two; |
37 | 41 | } |
38 | 42 |
|
39 | 43 | inline bool ScriptIterator::is_emoji(UChar32 p_c, UChar32 p_next) { |
40 | | - if (p_next == 0xFE0E) { // Variation Selector-15 |
| 44 | + if (p_next == VARIATION_SELECTOR_15 && (u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC))) { |
41 | 45 | return false; |
42 | | - } else if (p_next == 0xFE0F) { // Variation Selector-16 |
| 46 | + } else if (p_next == VARIATION_SELECTOR_16 && (u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC))) { |
43 | 47 | return true; |
44 | 48 | } else { |
45 | | - return u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_PRESENTATION) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_MODIFIER) || u_hasBinaryProperty(p_c, UCHAR_REGIONAL_INDICATOR) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC); |
| 49 | + return u_hasBinaryProperty(p_c, UCHAR_EMOJI_PRESENTATION) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_MODIFIER) || u_hasBinaryProperty(p_c, UCHAR_REGIONAL_INDICATOR); |
46 | 50 | } |
47 | 51 | } |
48 | 52 |
|
@@ -119,8 +123,7 @@ ScriptIterator::ScriptIterator(const String &p_string, int p_start, int p_length |
119 | 123 | } |
120 | 124 |
|
121 | 125 | if (script_code == USCRIPT_SYMBOLS_EMOJI && script_code != sc) { |
122 | | - UCharCategory cat = (UCharCategory)u_charType(ch); |
123 | | - if ((cat >= U_SPACE_SEPARATOR && cat <= U_CONTROL_CHAR) || (cat >= U_DASH_PUNCTUATION && cat <= U_OTHER_PUNCTUATION) || (cat >= U_INITIAL_PUNCTUATION && cat <= U_FINAL_PUNCTUATION)) { |
| 126 | + if (ch == VARIATION_SELECTOR_15 || n == VARIATION_SELECTOR_15 || !(is_emoji(ch, n) || ch == ZERO_WIDTH_JOINER || ch == VARIATION_SELECTOR_16 || u_hasBinaryProperty(ch, UCHAR_EXTENDED_PICTOGRAPHIC))) { |
124 | 127 | break; |
125 | 128 | } |
126 | 129 | } else if (same_script(script_code, sc)) { |
|
0 commit comments