I'm using this PHP function to wrap emojis in arbitrary HTML tags, which allows me to style them on web pages, since CSS3 does not (yet?) directly support styling of multi-byte characters, at least I haven't found any CSS selector for that purpose:
function wrap_emojis($s, $str_before, $str_after) {
$default_encoding = mb_regex_encoding();
mb_regex_encoding('UTF-8');
$s = mb_ereg_replace('([^\x{0000}-\x{FFFF}])', $str_before . '\\1' . $str_after, $s);
mb_regex_encoding($default_encoding);
return $s;
}
The issue is that it works for lower range emojis such as 😎 (01F60E) but it does not work for higher range emojis such as ☀️ (2600FE0F)
Any ideas how to fix the PHP function so that it works with 4 bytes range as well?
e.g. if I call wrap_emojis("zzz☀️zzz", "A", "B"); Expected result: "zzzA☀️Bzzz". Actual result: "zzz☀️zzz". But it works with lower range emojis as noted in the question, e.g. wrap_emojis("zzz😎zzz", "A", "B") returns: "zzzA😎Bzzz"
wrap_emojiswith the parameters and what to expect as result?