使用 PHP 将汉字转换为 Unicode

Pae*_*ski 1 php

PHP中有没有办法将汉字转换为Unicode?

e.g. (??) convert to (&#36023 ;&#22050 ;)
Run Code Online (Sandbox Code Playgroud)

Par*_*ait 5

function chineseToUnicode($str){
    //split word
    preg_match_all('/./u',$str,$matches);

    $c = "";
    foreach($matches[0] as $m){
            $c .= "&#".base_convert(bin2hex(iconv('UTF-8',"UCS-4",$m)),16,10);
    }
    return $c;
}
//Print result
$str = "????????????????????????Umbrella Movement ? Umbrella Revolution???2014?9?26????????????????????????60-70???????????????????????????????????????????????????????????????????????????2017????????2016?????????????????????????????????????????????";
echo chineseToUnicode($str);
Run Code Online (Sandbox Code Playgroud)

http://pastebin.com/zZfci0Dz

对于 Ryan(utf8 到 unicode + unicode 到 utf8)

PHP 中的完整示例代码

http://ideone.com/td1TUv