forPelevin / gomoji

Helpful functions to work with emoji in Golang
MIT License
190 stars 28 forks source link

Add support for "new-button" #8

Closed ricardogama closed 2 years ago

ricardogama commented 2 years ago

Seems like 🆕 is not included in the list (ref).

@forPelevin I don't know what to put in UnicodeName so I left a ? for now, let me know what to put there.

forPelevin commented 2 years ago

Hello @ricardogama! Thank you for your contribution. The emoji is in data already. You can find it at 3437 line of data.go

ricardogama commented 2 years ago

@forPelevin You're right, it's there! However, something's not working quite right.

I pushed a new commit removing the duplicated entry, but adding test cases for this particular emoji and they're failing.

Maybe you can checkout the code and debug what's going on?

ricardogama commented 2 years ago

@forPelevin By replacing the emoji on the list from my source I managed to make the tests pass, WDYT?

forPelevin commented 2 years ago

@ricardogama, thank you for the info. According to the debug printing, there is a hidden rune in your emoji: https://go.dev/play/p/5JtO7Yn_ylv

ricardogama commented 2 years ago

@forPelevin I see, that's an issue. I'm using this lib against user input to prevent errors when piping it to another destination.

It worked fine for all cases until now, but for this string in particular I got an error because the lib didn't strip it as I would expect.

At a glance, shouldn't uniseg.Graphemes cover this case? 🤔

forPelevin commented 2 years ago

@ricardogama Your emoji contains a variation selector (https://en.wikipedia.org/wiki/Variation_Selectors_(Unicode_block) I made a fix (https://github.com/forPelevin/gomoji/pull/9) to detect emojis of this type. Can you look into it? Is that fix ok for you?

ricardogama commented 2 years ago

Yes that works, I'm closing this one. Thanks!