| 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 <unicode/uniset.h> | 7 #include <unicode/uniset.h> |
| 8 | 8 |
| 9 using namespace WTF; | 9 using namespace WTF; |
| 10 using namespace Unicode; | 10 using namespace Unicode; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 static void applyPatternAndFreeze(icu::UnicodeSet* unicodeSet, const char* patte
rn) | 78 static void applyPatternAndFreeze(icu::UnicodeSet* unicodeSet, const char* patte
rn) |
| 79 { | 79 { |
| 80 UErrorCode err = U_ZERO_ERROR; | 80 UErrorCode err = U_ZERO_ERROR; |
| 81 // Use ICU's invariant-character initialization method. | 81 // Use ICU's invariant-character initialization method. |
| 82 unicodeSet->applyPattern(icu::UnicodeString(pattern, -1, US_INV), err); | 82 unicodeSet->applyPattern(icu::UnicodeString(pattern, -1, US_INV), err); |
| 83 unicodeSet->freeze(); | 83 unicodeSet->freeze(); |
| 84 ASSERT(err == U_ZERO_ERROR); | 84 ASSERT(err == U_ZERO_ERROR); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool Character::isEmoji(UChar32 ch) |
| 88 { |
| 89 return Character::isEmojiTextDefault(ch) || Character::isEmojiEmojiDefault(c
h); |
| 90 } |
| 91 |
| 87 bool Character::isEmojiTextDefault(UChar32 ch) | 92 bool Character::isEmojiTextDefault(UChar32 ch) |
| 88 { | 93 { |
| 89 DEFINE_STATIC_LOCAL(icu::UnicodeSet, emojiTextSet, ()); | 94 DEFINE_STATIC_LOCAL(icu::UnicodeSet, emojiTextSet, ()); |
| 90 if (emojiTextSet.isEmpty()) | 95 if (emojiTextSet.isEmpty()) |
| 91 applyPatternAndFreeze(&emojiTextSet, kEmojiTextPattern); | 96 applyPatternAndFreeze(&emojiTextSet, kEmojiTextPattern); |
| 92 return emojiTextSet.contains(ch) && !isEmojiEmojiDefault(ch); | 97 return emojiTextSet.contains(ch) && !isEmojiEmojiDefault(ch); |
| 93 } | 98 } |
| 94 | 99 |
| 95 bool Character::isEmojiEmojiDefault(UChar32 ch) | 100 bool Character::isEmojiEmojiDefault(UChar32 ch) |
| 96 { | 101 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 114 return (ch >= '0' && ch <= '9') || ch == '#'; | 119 return (ch >= '0' && ch <= '9') || ch == '#'; |
| 115 } | 120 } |
| 116 | 121 |
| 117 bool Character::isRegionalIndicator(UChar32 ch) | 122 bool Character::isRegionalIndicator(UChar32 ch) |
| 118 { | 123 { |
| 119 return (ch >= 0x1F1E6 && ch <= 0x1F1FF); | 124 return (ch >= 0x1F1E6 && ch <= 0x1F1FF); |
| 120 } | 125 } |
| 121 | 126 |
| 122 | 127 |
| 123 }; // namespace blink | 128 }; // namespace blink |
| OLD | NEW |