Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to match emoji keycap numbers 0-9, # and * #3

Closed
rodrigopolo opened this issue Oct 9, 2015 · 8 comments
Closed

Failing to match emoji keycap numbers 0-9, # and * #3

rodrigopolo opened this issue Oct 9, 2015 · 8 comments

Comments

@rodrigopolo
Copy link

I tested, all emojis available on iOS 9.1 / OS X 10.11.1 and it is failing to detect emoji numbers:

\u0030\ufe0f\u20e3
\u0031\ufe0f\u20e3
\u0032\ufe0f\u20e3
\u0033\ufe0f\u20e3
\u0034\ufe0f\u20e3
\u0035\ufe0f\u20e3
\u0036\ufe0f\u20e3
\u0037\ufe0f\u20e3
\u0038\ufe0f\u20e3
\u0039\ufe0f\u20e3
\u0023\ufe0f\u20e3
\u002a\ufe0f\u20e3

As typed

0️⃣
1️⃣
2️⃣
3️⃣
4️⃣
5️⃣
6️⃣
7️⃣
8️⃣
9️⃣
#️⃣
*️⃣
@beaugunderson
Copy link

👍 I noticed this as well, there are also ~70 emoji that can have a \uFE0F at the end, it's the emoji variation selector.

@beaugunderson
Copy link

Or maybe it's at the beginning... Hard to tell when there are adjacent emoji.

@beaugunderson
Copy link

Sorry, definitely supposed to be at the end: http://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.html

@rodrigopolo
Copy link
Author

One thing is "supposed" and other is "in practice", Apple, Google and Microsoft implement Emojis very differently, that's why after a long process I decided to create a regex using all emojis typed from the vendor devices (removing any duplicate) then sorting them by length, the big one first for replacement, then if a match is found I strip all the extra emoji characters that don't do something relevant, like the variant selector and the other that glues together emojis, in this way I can find any emoji and find their unicode representation easily.

@beaugunderson
Copy link

Sorry, I was only replying to my previous comment about \uFE0F appearing at the beginning or end of ~70 other emoji (in the non-keycap emoji it's supposed to be at the end), you are correct that it's supposed to be (and appears in practice) in the middle of the keycap emoji. :)

@mathiasbynens
Copy link
Owner

#2 (comment)

@pettedemon
Copy link

Hi,
I have a php function to remove the emoji, but how can I add these particular emoji in my function?

function remove_emoji($text){
  return preg_replace('/([0-9|#][\x{20E3}])|[\x{00ae}|\x{00a9}|\x{203C}|\x{2047}|\x{2048}|\x{2049}|\x{3030}|\x{303D}|\x{2139}|\x{2122}|\x{3297}|\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F6FF}][\x{FE00}-\x{FEFF}]?/u', '', $text);
}

@mathiasbynens
Copy link
Owner

@pettedemon Try Stack Overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants