<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>omiga &#187; substr</title>
	<atom:link href="http://omiga.org/blog/archives/tag/substr/feed" rel="self" type="application/rss+xml" />
	<link>http://omiga.org/blog</link>
	<description>两只老虎，两只老虎，跑得快，跑得快～···</description>
	<lastBuildDate>Fri, 20 Aug 2010 16:28:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>substr()</title>
		<link>http://omiga.org/blog/archives/777</link>
		<comments>http://omiga.org/blog/archives/777#comments</comments>
		<pubDate>Thu, 18 Dec 2008 04:51:44 +0000</pubDate>
		<dc:creator>omiga</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[substr]]></category>

		<guid isPermaLink="false">http://omiga.org/blog/?p=777</guid>
		<description><![CDATA[写了个获取最新评论的函数，用substr截取，后面总会莫名其妙地多个乱码，原来 ，substr() 函数只能正确截取单字节字符串，所以针对双字节或多字节编码的字符就得自己动手了～··· function sysSubStr($String,$Length,$Append=false){ if (strlen($String) &#60;= $Length ){ return $String; } else{ $I = 0; while ($I &#60; $Length){ $StringTMP = substr($String,$I,1); if ( ord($StringTMP) &#62;=224 ){ $StringTMP = substr($String,$I,3); $I = $I + 3; } elseif( ord($StringTMP) &#62;=192 ){ $StringTMP = substr($String,$I,2); $I = $I + 2; }else{ $I = $I + 1; [...]]]></description>
			<content:encoded><![CDATA[<p>写了个获取最新评论的函数，用substr截取，后面总会莫名其妙地多个乱码，原来<span class="dark bold"> </span><span id="articleSummary"> ，substr() 函数只能正确截取单字节字符串，所以针对双字节或多字节编码的字符就得自己动手了～···</span></p>
<pre><span>function sysSubStr($String,$Length,$Append=false){
	if (strlen($String) &lt;= $Length ){
		return $String;
	}
	else{
		$I = 0;
		while ($I &lt; $Length){
			$StringTMP = substr($String,$I,1);
			if ( ord($StringTMP) &gt;=224 ){
				$StringTMP = substr($String,$I,3);
				$I = $I + 3;
			}
			elseif( ord($StringTMP) &gt;=192 ){
				$StringTMP = substr($String,$I,2);
				$I = $I + 2;
			}else{
				$I = $I + 1;
			}
			$StringLast[] = $StringTMP;
		}
		$StringLast = implode("",$StringLast);
		if($Append){
			$StringLast .= "...";
		}
		return $StringLast;
	}
}
</span></pre>
<p><span>更多的在这里：<a href="http://www.codebit.cn/pub/html/php_mysql/tip/data/substr/" target="_blank">http://www.codebit.cn/pub/html/php_mysql/tip/data/substr/</a></span></p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li><a href="http://omiga.org/blog/archives/565" title="再玩PHP">再玩PHP</a></li><li><a href="http://omiga.org/blog/archives/153" title="PHP and JSON">PHP and JSON</a></li></ul><hr />
<p><small>© omiga for <a href="http://omiga.org/blog">omiga</a>, 2008. |
<a href="http://omiga.org/blog/archives/777">Permalink</a> |
<a href="http://omiga.org/blog/archives/777#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://omiga.org/blog/archives/777&title=substr()">del.icio.us</a>
<br/>
Post tags: <a href="http://omiga.org/blog/archives/tag/php" rel="tag">PHP</a>, <a href="http://omiga.org/blog/archives/tag/substr" rel="tag">substr</a><br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://omiga.org/blog/archives/777/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
