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

Normalize codepoints for Twemoji #9

Merged
merged 5 commits into from
Feb 5, 2022

Conversation

tobyzerner
Copy link
Contributor

@tobyzerner tobyzerner commented Feb 2, 2022

This PR piggybacks on #6. cc/ @JoshyPHP

I noticed some random emojis weren't being converted, even with #6. Things like 🏝, ❀️‍πŸ”₯, and πŸƒπŸ»β€β™€οΈ.

Now I'll be honest, I have no idea how Unicode works.

But I know that @JoshyPHP does, so I tried adapting this logic from the s9e/TextFormatter Emoji plugin, to normalize the codepoints so they work with Twemoji:

// Twemoji sequence, leading zeroes are removed and VS-16 are removed from non-ZWJ sequences
$tseq = ltrim($hex, '0');
if (strpos($tseq, '-200d') === false)
{
    $tseq = str_replace('-fe0f', '', $tseq);
}

And lo and behold, it works! I added some tests with some of the more complex emojis that were failing before, which work great now.

@Gummibeer Gummibeer merged commit eaf829c into Astrotomic:main Feb 5, 2022
@Gummibeer
Copy link
Member

Hey, thanks for your contribution and sorry for the massive delay! πŸ™
It's released now. πŸŽ‰πŸš€
https://github.com/Astrotomic/php-twemoji/releases/tag/0.2.2

In case you want to check why it took so long:
https://gummibeer.dev/blog/2022/end-of-an-era/

@tobyzerner
Copy link
Contributor Author

Hey @Gummibeer, thanks for sharing your story. I can definitely relate! Glad you're on a better path now. Wishing you all the best. Thank you for the merge + release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants