| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/text/Character.h" | 5 #include "platform/text/Character.h" |
| 6 | 6 |
| 7 #include "platform/text/ICUError.h" | 7 #include "platform/text/ICUError.h" |
| 8 #include <unicode/uvernum.h> | 8 #include <unicode/uvernum.h> |
| 9 | 9 |
| 10 #if defined(USING_SYSTEM_ICU) || (U_ICU_VERSION_MAJOR_NUM <= 57) | 10 #if defined(USING_SYSTEM_ICU) || (U_ICU_VERSION_MAJOR_NUM <= 57) |
| 11 #include <unicode/uniset.h> | 11 #include <unicode/uniset.h> |
| 12 #else | 12 #else |
| 13 #include <unicode/uchar.h> | 13 #include <unicode/uchar.h> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 using namespace WTF; | 16 using namespace WTF; |
| 17 using namespace Unicode; | 17 using namespace Unicode; |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 // ICU 57 or earlier does not have up to date Emoji properties, so we're | 21 // ICU 57 or earlier does not have up to date Emoji properties, so we're |
| 22 // temporarily uing our own functions again. Compare crbug.com/628333 Other than | 22 // temporarily uing our own functions again. Compare crbug.com/628333 Other than |
| 23 // that: versions before 56 do not have an API for Emoji properties, but | 23 // that: versions before 56 do not have an API for Emoji properties, but |
| 24 // Chrome's copy of ICU 56 does. | 24 // Chrome's copy of ICU 56 does. |
| 25 #if defined(USING_SYSTEM_ICU) || (U_ICU_VERSION_MAJOR_NUM <= 57) | 25 #if defined(USING_SYSTEM_ICU) && (U_ICU_VERSION_MAJOR_NUM <= 57) |
| 26 // The following UnicodeSet patterns were compiled from | 26 // The following UnicodeSet patterns were compiled from |
| 27 // http://www.unicode.org/Public/emoji/3.0//emoji-data.txt | 27 // http://www.unicode.org/Public/emoji/3.0//emoji-data.txt |
| 28 | 28 |
| 29 // The following patterns can be generated from the respective sections of the | 29 // The following patterns can be generated from the respective sections of the |
| 30 // emoji_data.txt file by using the following Elisp function in Emacs. | 30 // emoji_data.txt file by using the following Elisp function in Emacs. |
| 31 // Known issues: | 31 // Known issues: |
| 32 // 1) Does not insert the double [[ and ]] at the beginning and end of the | 32 // 1) Does not insert the double [[ and ]] at the beginning and end of the |
| 33 // pattern. | 33 // pattern. |
| 34 // 2) Does not insert \U0000 at the very last codepoint of a pattern. | 34 // 2) Does not insert \U0000 at the very last codepoint of a pattern. |
| 35 // | 35 // |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 !u_hasBinaryProperty(ch, UCHAR_EMOJI_PRESENTATION); | 226 !u_hasBinaryProperty(ch, UCHAR_EMOJI_PRESENTATION); |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool Character::isEmojiEmojiDefault(UChar32 ch) { | 229 bool Character::isEmojiEmojiDefault(UChar32 ch) { |
| 230 return u_hasBinaryProperty(ch, UCHAR_EMOJI_PRESENTATION); | 230 return u_hasBinaryProperty(ch, UCHAR_EMOJI_PRESENTATION); |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool Character::isEmojiModifierBase(UChar32 ch) { | 233 bool Character::isEmojiModifierBase(UChar32 ch) { |
| 234 return u_hasBinaryProperty(ch, UCHAR_EMOJI_MODIFIER_BASE); | 234 return u_hasBinaryProperty(ch, UCHAR_EMOJI_MODIFIER_BASE); |
| 235 } | 235 } |
| 236 #endif // defined(USING_SYSTEM_ICU) && (U_ICU_VERSION_MAJOR_NUM <= 56) | 236 #endif // defined(USING_SYSTEM_ICU) && (U_ICU_VERSION_MAJOR_NUM <= 57) |
| 237 | 237 |
| 238 bool Character::isEmojiKeycapBase(UChar32 ch) { | 238 bool Character::isEmojiKeycapBase(UChar32 ch) { |
| 239 return (ch >= '0' && ch <= '9') || ch == '#' || ch == '*'; | 239 return (ch >= '0' && ch <= '9') || ch == '#' || ch == '*'; |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool Character::isRegionalIndicator(UChar32 ch) { | 242 bool Character::isRegionalIndicator(UChar32 ch) { |
| 243 return (ch >= 0x1F1E6 && ch <= 0x1F1FF); | 243 return (ch >= 0x1F1E6 && ch <= 0x1F1FF); |
| 244 } | 244 } |
| 245 | 245 |
| 246 }; // namespace blink | 246 }; // namespace blink |
| OLD | NEW |