note 110575 added to function.json-encode
| From: | Yuri | Date: | Thu, 08 Nov 2012 19:27:13 +0000 |
| Subject: | note 110575 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191813@lists.php.net to get a copy of this message | ||
If you need get unescaped unicode on PHP version < 5.4, you can use this function:
<?php
// For PHP <= 5.3
function utf8_unescape($source){
return preg_replace('/\\\u([0-9A-F]{4})/sei', 'iconv("utf-16",
"utf-8", hex2str("$1"))', $source);
}
function hex2str($hex) {
$r = '';
for ($i = 0; $i < strlen($hex) - 1; $i += 2)
$r .= chr(hexdec($hex[$i] . $hex[$i + 1]));
return $r;
}
// Example
echo utf8_unescape("\u041f\u0440\u0438\u0432\u0435\u0442");
?>
----
Server IP: 69.147.83.199
Probable Submitter: 94.228.254.82
----
Manual Page -- http://www.php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/110575
Del: integrated -- https://master.php.net/note/delete/110575/integrated
Del: useless -- https://master.php.net/note/delete/110575/useless
Del: bad code -- https://master.php.net/note/delete/110575/bad+code
Del: spam -- https://master.php.net/note/delete/110575/spam
Del: non-english -- https://master.php.net/note/delete/110575/non-english
Del: in docs -- https://master.php.net/note/delete/110575/in+docs
Del: other reasons-- https://master.php.net/note/delete/110575
Reject -- https://master.php.net/note/reject/110575
Search -- https://master.php.net/manage/user-notes.php