代码如下: function cut_str($sourcestr,$cutlength) { $returnstr=”; $i=0; $n=0; $str_length=strlen($sourcestr);//字符串的字节数 while (($n<$cutlength) and ($i<=$str_length)) { $temp_str=substr($sourcestr,$i,1); $ascnum=Ord($temp_str);//得到字符串中第$i位字符的ascii码 if ($ascnum>=224) //如果ASCII位高与224, { //根据UTF-8编码规范,将3个连续的