Merge "Update isNewEmoji to check Unicode 12." into qt-dev

This commit is contained in:
Qingqing Deng
2019-05-21 20:56:11 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 14 deletions

View File

@@ -73,22 +73,20 @@ public class Emoji {
* Returns true if the character is a new emoji still not supported in our version of ICU.
*/
public static boolean isNewEmoji(int c) {
// Emoji characters new in Unicode emoji 11
// From https://www.unicode.org/Public/emoji/11.0/emoji-data.txt
// TODO: Remove once emoji-data.text 11 is in ICU or update to 11.
if (c < 0x1F6F9 || c > 0x1F9FF) {
// Emoji characters new in Unicode emoji 12
// From https://www.unicode.org/Public/emoji/12.0/emoji-data.txt
// TODO: Remove once emoji-data.text 12 is in ICU or update to 12.
if (c < 0x1F6D5 || c > 0x1FA95) {
// Optimization for characters outside the new emoji range.
return false;
}
return c == 0x265F || c == 0x267E || c == 0x1F6F9 || c == 0x1F97A
|| (0x1F94D <= c && c <= 0x1F94F)
|| (0x1F96C <= c && c <= 0x1F970)
|| (0x1F973 <= c && c <= 0x1F976)
|| (0x1F97C <= c && c <= 0x1F97F)
|| (0x1F998 <= c && c <= 0x1F9A2)
|| (0x1F9B0 <= c && c <= 0x1F9B9)
|| (0x1F9C1 <= c && c <= 0x1F9C2)
|| (0x1F9E7 <= c && c <= 0x1F9FF);
return c == 0x1F6D5 || c == 0x1F6FA || c == 0x1F93F || c == 0x1F971 || c == 0x1F97B
|| (0x1F7E0 <= c && c <= 0x1F7EB) || (0x1F90D <= c && c <= 0x1F90F)
|| (0x1F9A5 <= c && c <= 0x1F9AA) || (0x1F9AE <= c && c <= 0x1F9AF)
|| (0x1F9BA <= c && c <= 0x1F9BF) || (0x1F9C3 <= c && c <= 0x1F9CA)
|| (0x1F9CD <= c && c <= 0x1F9CF) || (0x1FA70 <= c && c <= 0x1FA73)
|| (0x1FA78 <= c && c <= 0x1FA7A) || (0x1FA80 <= c && c <= 0x1FA82)
|| (0x1FA90 <= c && c <= 0x1FA95);
}
/**

View File

@@ -40,7 +40,7 @@ import org.junit.runner.RunWith;
public class EmojiTest {
@Test
public void testIsNewEmoji_Emoji5() {
public void testIsNewEmoji_Emoji() {
// each row in the data is the range of emoji
final int[][][] data = new int[][][]{
{ // EMOJI 5
@@ -66,6 +66,24 @@ public class EmojiTest {
{0x1F9B0, 0x1F9B9},
{0x1F9C1, 0x1F9C2},
{0x1F9E7, 0x1F9FF},
},
{ // EMOJI 12
{0x1F6D5, 0x1F6D5},
{0x1F6FA, 0x1F6FA},
{0x1F93F, 0x1F93F},
{0x1F971, 0x1F971},
{0x1F97B, 0x1F97B},
{0x1F7E0, 0x1F7EB},
{0x1F90D, 0x1F90F},
{0x1F9A5, 0x1F9AA},
{0x1F9AE, 0x1F9AF},
{0x1F9BA, 0x1F9BF},
{0x1F9C3, 0x1F9CA},
{0x1F9CD, 0x1F9CF},
{0x1FA70, 0x1FA73},
{0x1FA78, 0x1FA7A},
{0x1FA80, 0x1FA82},
{0x1FA90, 0x1FA95}
}
};