note 76467 deleted from function.preg-replace by cmb
| From: | cmb@php.net | Date: | Sun, 22 Sep 2019 08:02:36 +0000 |
| Subject: | note 76467 deleted from function.preg-replace by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212308@lists.php.net to get a copy of this message | ||
Note Submitter: 131 dot php at cloudyks dot org
----
Based on previous comment, i suggest
( this function already exist in php 6 )
<?php
function unicode_decode($str){
return preg_replace(
'#\\\u([0-9a-f]{4})#e',
"unicode_value('\\1')",
$str);
}
function unicode_value($code) {
$value=hexdec($code);
if($value<0x0080)
return chr($value);
elseif($value<0x0800)
return chr((($value&0x07c0)>>6)|0xc0)
.chr(($value&0x3f)|0x80);
else
return chr((($value&0xf000)>>12)|0xe0)
.chr((($value&0x0fc0)>>6)|0x80)
.chr(($value&0x3f)|0x80);
}
?>
[EDIT BY danbrown AT php DOT net: This function originally written by mrozenoer AT overstream DOT
net.]