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

Support alias back-and-forth #8

Open
liemle3893 opened this issue Mar 30, 2021 · 5 comments
Open

Support alias back-and-forth #8

liemle3893 opened this issue Mar 30, 2021 · 5 comments

Comments

@liemle3893
Copy link

liemle3893 commented Mar 30, 2021

Hi there,
I found this module is quite interesting and easy to catch up.

Currently, I got into situation where I need to implement some kind of searching, but the search engine is not fully support utf8. So, it's may good for user to be able to convert ❤️ => :heart: and back, :heart: => ❤️

I'm also done a prototype for these implementation. My repo: liemle3893@985fe95

It's cool if we can add this feature.

Regards.

@quenbyako
Copy link

wait, are these symbols not equal?

for me it looks like this Screen Shot 2021-03-31 at 3 54 51 AM

@liemle3893
Copy link
Author

@quenbyako oops, my bad. I've updated.

Shoud be: :heart: => ❤️ and back, ❤️ => :heart:

@quenbyako
Copy link

quenbyako commented Mar 31, 2021

@liemle3893 why you just don't make reverse map searching? It's really trivial: you just finding key by ranging values 🙃

Also, there is even more simple way: why just not copy emoji.Map() and flip keys and values to your map? I mean, i understand your problem, but it is really simple, and you can can solve it even simpler than you think and without improving current code.

But, even i'm not author or contributor to this project, i appreciate your work, no matter how much there are more solutions of this issue exist

@adbenitez
Copy link

@quenbyako for a single emoji, yeah sure, it is easy to convert ❤️ => :heart: but if your input is a text like "I ❤️ emoji" then you have to parse the text looking for all emoji, another feature that is not supported by this library so if something like emoji.FindAll(text) is added to allow getting all emoji in text maybe it would be easy to implement, but right now user has to parse text looking for emoji themselves

@adbenitez
Copy link

adbenitez commented Apr 4, 2023

another option is to use https://github.com/forPelevin/gomoji which allows to replace emojis with their slug, then use this library for the other direction 🤦 each library support the conversion only in one direction

func replaceEmojisWithSlug(s string) string {
	return gomoji.ReplaceEmojisWithFunc(s, func(em gomoji.Emoji) string {
		return ":" + em.Slug + ":"
	})
}

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

3 participants