function get_bianma($str)//等同于js的charCodeAt()
{
$result = array();
for($i = 0, $l = mb_strlen($str, 'utf-8');$i < $l;++$i)
{
$result[] = uniord(mb_substr($str, $i, 1, 'utf-8'));
}
return join(",", $result);
}
function uniord($str, $from_encoding = false)
{
$from_encoding = $from_encoding ? $from_encoding : 'UTF-8';
if (strlen($str) == 1)
return ord($str);
$str = mb_convert_encoding($str, 'UCS-4BE', $from_encoding);
$tmp = unpack('N', $str);
return $tmp[1];
}
说明:
get_bianma(substr($enc_str, $i, 1))
等同于js代码
enc_str.charCodeAt(i)