unicode.net icon indicating copy to clipboard operation
unicode.net copied to clipboard

Reverse lookup emoji name

Open PeturDarriPeturs opened this issue 2 years ago • 4 comments

I'm trying to look up the emoji name given a UnicodeSequence. Since the Emoji class has all the emoji with their names, I assumed I would be able to look it up. But that does not appear to be possible.

I tried using SortedSet.TryGetValue on Emoji.All, giving it an incomplete SingleEmoji with just the sequence, but it fails to find it. It appears to be because the SortedSet is sorted by the custom SortOrder assigned to each emoji, so it doesn't compare the sequences.

PeturDarriPeturs avatar Oct 16 '23 17:10 PeturDarriPeturs

I worked around this problem by converting the SortedSet to a Dictionary at startup. It's not ideal to need to have two collections of the same thing in memory, but I guess it can't be helped if the original Unicode sorting order needs to be maintained.

PeturDarriPeturs avatar Oct 17 '23 10:10 PeturDarriPeturs

Can you tell me more about your exact use case? Usually people use "friendlier" names than the official unicode names, like face_palm or lol, etc.

mqudsi avatar Oct 17 '23 16:10 mqudsi

The names in this repo are a bit friendlier than that, like person facepalming for face palm, and woman facepalming: medium-light skin tone for one of the variants.

My immediate use case is a temporary one: I'm working with emojis, but in an environment where I can't easily display them. I still want to know what they are, so I convert them to their name so I can print them.

PeturDarriPeturs avatar Oct 17 '23 16:10 PeturDarriPeturs

Oh I think I misunderstood your definition of friendly. In my case, I want it to be accurate, but I agree, the verbose names from Unicode aren't really commonly used. And especially for emoji that have a common interpretation in popular culture, but where Unicode is more literal.

Since this can be worked around, I don't think this needs any action, but I was surprised that it wasn't an option.

PeturDarriPeturs avatar Oct 17 '23 16:10 PeturDarriPeturs