不间断空格(non-breaking space),即前端页面上的
UTF-8编码中ASCII为194和160表示为 no-break space空格,unicode表示为 \xc2 和\xa0 或者是 \u00c2\u00a0,即 c2a0 ,会被HTML转义为
0xC2A0 - 0xC2 (194) and 0xA0 (160)
$space = chr(194);
# no-break space 转义为 nbsp
$nbsp = htmlentities($space, ENT_COMPAT, "UTF-8");
# nbsp 转义为 no-break space
$space = html_entity_decode($nbsp, ENT_COMPAT, "UTF-8");
# 替换 no-break space 为普通空格
$str = str_replace("\xc2\xa0", ' ', $str);
检测是否存在 no-break space空格
for($i=0; $i < strlen($code); $i++){
if(ord($code[$i] === 160 or ord($code[$i] === 194){
echo $i .' '. ord($code[$i]) . "<br>\r\n";
}
}
浙公网安备 33010602011771号