From c1188a08697794f43ff6361f1a1f72db67268b04 Mon Sep 17 00:00:00 2001 From: Mauro Cassani Date: Fri, 22 Dec 2023 16:35:50 +0100 Subject: [PATCH] Emoji fix --- src/Utils/Emoji.php | 8 ++++++-- tests/EmojiTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Utils/Emoji.php b/src/Utils/Emoji.php index e3913e7..624825c 100644 --- a/src/Utils/Emoji.php +++ b/src/Utils/Emoji.php @@ -6897,7 +6897,7 @@ class Emoji { '๐Ÿผ' => '🏼', '๐Ÿฝ' => '🏽', '๐Ÿพ' => '🏾', - '๐ŸŸฟ' => '🏿', + '๐Ÿฟ' => '🏿', '๏ธ' => '️', 'โƒฃ' => '⃣', '๐€' => '𝐀', @@ -7401,7 +7401,7 @@ class Emoji { '๔ฐ€' => '􏰀', '๐Ÿ›ผ' => '🛼', '๐Ÿฅท' => '🥷', - '๐ŸคŒ' => '🏼', + '๐ŸคŒ' => '🤌', "๓ …ธ" => '󠅸', // invisible glyph '๓ „€' => '󠄀', '๓ ‡ก' => '󠇡', @@ -7463,6 +7463,10 @@ public static function toEntity( $str ) { return $str; } + /** + * @param $str + * @return string + */ public static function toEmoji( $str ) { self::generateReverseMap(); preg_match_all( '/&#[0-9a-fA-F]+;/', $str, $emoji_entity_list, PREG_PATTERN_ORDER ); diff --git a/tests/EmojiTest.php b/tests/EmojiTest.php index 9fa4e07..2aadde5 100644 --- a/tests/EmojiTest.php +++ b/tests/EmojiTest.php @@ -124,4 +124,28 @@ public function entityToEmojiTest() { $this->assertEquals( 'Questo โœ• รจ un emoji a croce ๔€…–๐Ÿช™ manina ๐Ÿ‘‹๐Ÿป', Emoji::toEmoji( $segment ) ); } + /** + * This test is performed on the same emoji (flexed arm) in different shades + * + * @test + */ + public function canEncodeAndDecodeDifferentShades() + { + $emojis = [ + '๐ŸคŒ', + '๐Ÿ’ช๐Ÿป', + '๐Ÿ’ช๐Ÿฝ', + '๐Ÿ’ช๐Ÿพ', + '๐Ÿ’ช๐Ÿฟ', + '๐Ÿ’ช๐Ÿผ' + ]; + + foreach ($emojis as $i => $emoji){ + + $entity = Emoji::toEntity($emoji); + $toEmoji = Emoji::toEmoji($entity); + + $this->assertEquals($emojis[$i], $toEmoji); + } + } } \ No newline at end of file