Last active
October 9, 2018 03:12
-
-
Save lovelock/9056d4cbd60a3791caf8c58b7260bc28 to your computer and use it in GitHub Desktop.
convert unicode characters to utf8
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 | |
$str = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) { | |
if ($match) { | |
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UTF-16BE'); | |
} | |
}, $str); |
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 | |
$str = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) { | |
if ($match) { | |
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); | |
} | |
}, $str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment