Skip to content

Commit

Permalink
set encoding before running mb_strlen
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Nov 30, 2017
1 parent 80763a9 commit fb07658
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Emoji.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb07658

Please sign in to comment.