PHP计算字符串宽度,英文字符、数字等ASCII字符记长度为1,汉字等多字节字符长度计2

<?php
function abslength($s){
	$n = 0;
	preg_match_all("/./us",$s,$matchs);
	foreach($matchs[0] as $p){
		$n += preg_match('#^['.chr(0x1).'-'.chr(0xff).']$#',$p) ? 1 : 2;
	}
	return $n;
}
echo abslength("a我们阿萨德as123");