Last active
February 16, 2018 19:24
-
-
Save pfeiffer/3540bd86c5547d574f5216cd51392037 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('emoji.php'); // Provides a $GLOBALS['emoji_maps'] etc.. | |
function emoji_unified_to_code($text){ | |
return preg_replace_callback($GLOBALS['emoji_maps']['unified_rx'], function($m){ | |
if (isset($m[2]) && $m[2] == "\xEF\xB8\x8E") return $m[0]; | |
$cp = $GLOBALS['emoji_maps']['unified_to_html'][$m[1]]; | |
return "[emoji{$cp}]"; | |
}, $text); | |
} | |
function emoji_code_to_unified($text){ | |
return preg_replace_callback("!\[emoji([0-9a-f]+)\]!", function($m){ | |
if (isset($GLOBALS['emoji_maps']['html_to_unified'][$m[1]])){ | |
return $GLOBALS['emoji_maps']['html_to_unified'][$m[1]]; | |
} | |
return $m[0]; | |
}, $text); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment