Decode на unicode cyrillic

Идеята е да се декодира unicode cyrillic със php. Ето един простичък метод:

function unicode_decode($str)                                                                                                               {
return preg_replace(„/\\\u([0-9A-F]{4})/ie“, „iconv(‘utf-16’, ‘utf-8’, hex2str(\“$1\“))“, $str);
}

function hex2str($hex)
{
$r = “;
for ($i = 0; $i; $r .= chr(hexdec($hex[$i] . $hex[$i + 1])))
return $r;
}

Категория:

Logged in as {{omniform_current_user_display_name}}. Edit your profile. Log out? Required fields are marked *

Your email address will not be published. Required fields are marked *

Comments are closed.

You must be logged in to post a comment.