enescakir / emoji

A minimalistic emoji package for Go (golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support alias back-and-forth

liemle3893 opened this issue · comments

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.

wait, are these symbols not equal?

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

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

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

@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

@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

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 + ":"
	})
}