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

Reverse lookup emoji name #24

Open
PeturDarriPeturs opened this issue Oct 16, 2023 · 4 comments
Open

Reverse lookup emoji name #24

PeturDarriPeturs opened this issue Oct 16, 2023 · 4 comments

Comments

@PeturDarriPeturs
Copy link

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
Copy link
Author

PeturDarriPeturs commented Oct 17, 2023

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.

@mqudsi
Copy link
Member

mqudsi commented Oct 17, 2023

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.

@PeturDarriPeturs
Copy link
Author

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
Copy link
Author

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.

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

2 participants