Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Decode Unicode strings in PHP
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
$str = unicode_decode('\u00e9');

This comment has been minimized.

Copy link

nikhilavyatech commented Jul 28, 2017

Nice, really appreciable. Thanks


This comment has been minimized.

Copy link

alitayfur commented Nov 25, 2017

$str = utf8_decode(unicode_decode('\u00e9'));

nice Thanks for snipped 🗡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.