vdurmont / emoji-java

The missing emoji library for Java :heart:
MIT License
2.62k stars 514 forks source link

Fix missing variation selectors #178

Open Johnibur opened 3 years ago

Johnibur commented 3 years ago

Some emojis are missing the variation selector character (\uFE0F) used to specify a glyph to be applied to a preceding character, which makes them systematically fail the parsing test.

This first commit adds the missing character selectors for keycap enclosing digits. But there is likely to have such characters missing for other emojis.

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.3%) to 92.625% when pulling d72c7361393b39b5f77abd641e9681d4e09a2b72 on Johnibur:fix-missing-variation-selectors into 9a90624aa0a50f1785d6a10e1fcb2a296ce468f7 on vdurmont:master.

yanghanxy commented 3 years ago

I meet with the same problem, and found another emoji ❤️ missing with the variation selector character (\uFE0F)

yanghanxy commented 3 years ago

directly removing all variation selectors may helps

// remove Variation Selectors for Emoji glyph
StringBuilder sb = new StringBuilder();
for (char ch : sentenceText.toCharArray()) {
    Character.UnicodeBlock ub = Character.UnicodeBlock.of(ch);
    if (ub != Character.UnicodeBlock.VARIATION_SELECTORS && ub != Character.UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT) {
        sb.append(ch);
    }
}
sentenceText = sb.toString();