From fb0765845e554f04ccd2b594a7ab8ca44d804bab Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Thu, 30 Nov 2017 13:02:53 -0800 Subject: [PATCH] set encoding before running mb_strlen --- src/Emoji.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Emoji.php b/src/Emoji.php index f268ded..f29e3dc 100644 --- a/src/Emoji.php +++ b/src/Emoji.php @@ -3,8 +3,6 @@ define('LONGEST_EMOJI', 8); -mb_internal_encoding('UTF-8'); - function detect_emoji($string) { // Find all the emoji in the input string @@ -66,14 +64,14 @@ function detect_emoji($string) { } function is_single_emoji($string) { + $prevencoding = mb_internal_encoding(); + mb_internal_encoding('UTF-8'); + // If the string is longer than the longest emoji, it's not a single emoji if(mb_strlen($string) >= LONGEST_EMOJI) return false; $all_emoji = detect_emoji($string); - $prevencoding = mb_internal_encoding(); - mb_internal_encoding('UTF-8'); - $emoji = false; // If there are more than one or none, return false immediately