求教,怎么判断是否是低字节

WBOY
Release: 2016-06-13 12:34:27
Original
752 people have browsed it

求教,如何判断是否是低字节?

<?php<br />
header("content-type:text/html;charset=gbk");<br />
$str="j这是ces测试dkfjdksj";<br />
<br />
function substr_gbk($str,$start,$end)<br />
{<br />
	$temp="";<br />
	for($i=$start;$i<=$end;$i++)<br />
	{<br />
		if(ord($str{$i})>0xa0)<br />
		{<br />
			$temp.=substr($str,$i,2);<br />
			$i++;<br />
		}else<br />
		{<br />
			$temp.=substr($str,$i,1);<br />
		}<br />
	}<br />
	return $temp;<br />
}<br />
<br />
echo substr_gbk($str,1,10); //从高字节截取正常<br />
echo substr_gbk($str,2,10); //从低字节截取出现乱码<br />
?><br />
Copy after login


以上代码从高字节截取没有问题,但如果从低字节截取出现乱码
请问有知道如果判断高低字节的办法吗?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!