emoji icon indicating copy to clipboard operation
emoji copied to clipboard

Support alias back-and-forth

Open liemle3893 opened this issue 3 years ago • 5 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: https://github.com/liemle3893/emoji/commit/985fe954b73baf6614a2fd99d03779e49e07212d

It's cool if we can add this feature.

Regards.

liemle3893 avatar Mar 30 '21 19:03 liemle3893

wait, are these symbols not equal?

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

quenbyako avatar Mar 31 '21 00:03 quenbyako

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

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

liemle3893 avatar Mar 31 '21 02:03 liemle3893

@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 avatar Mar 31 '21 23:03 quenbyako

@quenbyako for a single emoji, yeah sure, it is easy to convert :heart: => :heart: but if your input is a text like "I :heart: 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 avatar Apr 04 '23 05:04 adbenitez

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

adbenitez avatar Apr 04 '23 05:04 adbenitez