1、JS中charCodeAt()函数方法可返回指定位置的字符的 Unicode 编码而非UTF-8编码
2、
private function charAtToStr($str)
{
$ret = array();
$len = mb_strlen($str,'utf-8');
for($i=0;$i<$len;$i++)
{
$ret[] = $this->charCodeAt($str[$i],0);
}
return (implode("", $ret));
}
private function charCodeAt($str,$index)
{
$char = mb_substr($str, $index,1,'UTF-8');
if(mb_check_encoding($char,'UTF-8'))
{
$ret = mb_convert_encoding($char, "UCS-4BE");
$ret = unpack("N", $ret);
$ret = dechex($ret[1]);
return $ret;
}else
{
return null;
}
}