Home Β» Php Β» php – Convert to full unicode string

php – Convert to full unicode string

Posted by: admin February 25, 2020 Leave a comment


How can I convert a string from \uD83D\uDE00 to full \U0001f603?
json_encode() only converts to the first option…

$str = 'πŸ˜ƒ';
$encode = json_encode($str);

// string(14) ""\ud83d\ude03""
How to&Answers:

Assuming you have the Intl extension installed, this is easy enough to do with one of its built-in transliterators:

$str = "πŸ˜€";
echo transliterator_create("Any-Hex/C")->transliterate($str);