Emoji icon indicating copy to clipboard operation
Emoji copied to clipboard

added property to Emoji class to be used for pattern matching purposes

Open johnearlelevado opened this issue 4 years ago • 6 comments

This is to fix issues #485 and #484. I added a new property for Emoji for pattern matching purposes. The issue was that whenever the emoji has more than one code point, EmojiUtils.isOnlyEmojis() doesn't work.

johnearlelevado avatar Jan 19 '21 04:01 johnearlelevado

@vanniktech if it works and it's better than what we currently have, why not? :)

mario avatar Jul 21 '21 06:07 mario

@rubengees poke here again :P

mario avatar Sep 26 '21 04:09 mario

@tricksilver04 I've added test for this: https://github.com/vanniktech/Emoji/pull/578

I tried your changes locally and unignored the test, however it's failing for the red emoji heart. Can you please have another look?

vanniktech avatar Apr 26 '22 09:04 vanniktech

@vanniktech I debugged this a bit and have the following findings:

  • Some emojis can optionally have a variant selector which denotes the previous emoji to be rendered as an emoji instead of text. We have multiple emojis that can have this variant selector.
  • Our datasource includes information about this. If the emoji can have a variant selector, the non_qualified field is not null. I tried to extend the generator to take this into account and made the tests pass except for the red heart exclamation.
  • I saw that we already specifically handle the star emoji with a variant selector. Interestingly that emoji does not appear in our data source as such a case.
  • The red heart exclamation seems to be either invalid or a special case. The code points are [10083, 65039, 65039] or 2763-FE0F-FE0F in hex. 2763-FE0F would be the heart exclamation with variant selector, but as we can see it has an additional variant selector! I'm not sure if multiple variant selectors are valid but e.g. browsers seem to ignore the second one.

I can think of two solutions:

  • Strip all variant selectors from the text before processing it in either the utils or when rendering the images. We want to display everything as an emoji either way.
  • Extend the generator to include this information in our code and handle it accordingly. Weird cases like the double variant selector would not work properly though I think.

rubengees avatar Apr 26 '22 12:04 rubengees

I saw that we already specifically handle the star emoji with a variant selector.

Yes if I remember correctly, we've had a report about this in the past and did a fix for it. (without thinking about all of the other emojis like described here)


Can we do a mix that we adjust the generator to include the information and just get rid of the double variant selector ourself?

vanniktech avatar Apr 26 '22 18:04 vanniktech

@rubengees I just saw this

https://github.com/vanniktech/Emoji/blob/b1155d5146237d7c6e60734734a861eea10ce645/generator/index.js#L248

This is where we handle the star

vanniktech avatar May 04 '22 11:05 vanniktech