讨论对中文文章分行进行处理,但出现乱码的问题!在线等!
先请看看:
1、http://gnovels.com/show.php?id=shangqing&&name=1308&&showdetail=yes
2、http://gnovels.com/show1.php?id=shangqing&&name=1308&&showdetail=yes
1是没有处理的,2的部分代码如下:
for( $i = $yjBegin; $i < $yjEnd; $i++ )
{
$tmpmsg = $message[$i];//取出一段文章
$msg_len = strlen( $tmpmsg );
$BeiginCount = 0;
$EndCount = 104;//每段大于104则分行
$nCount= 0;
while ( $msg_len > $EndCount )
{
$jj = 0;
$num = 104;
for ( $ii = $BeiginCount ; $ii < $EndCount; $ii++ )
{
if ( ord ( substr( $tmpmsg, $ii, 1 ) ) > 0xa0 )
{
$jj++;
}
}
if ( $jj % 2 != 0 )
{
$num++;
}
$str[ $nCount ] = substr( $tmpmsg, $BeiginCount, $num );
$BeiginCount = $BeiginCount + $num;
$EndCount = $BeiginCount + $num;
$nCount = $nCount + 1;
$str[ $nCount ] = substr( $tmpmsg, $BeiginCount );
}
//输出部分,如果没有分行,则直接输出。
if ( $nCount == 0 )
{
if ( ltrim( $tmpmsg ) == "" || ltrim( $tmpmsg ) == "<br>" )
continue;
print("<tr align=left valign=top>");
print("<td><span class=p4><font color=#000000>$tmpmsg </font></span></td>\n");
print("</tr>");
}
else
{
for ( $fcount = 0; $fcount <= $nCount; $fcount++ )
{
print("<tr align=left valign=top>");
print("<td><span class=p4><font color=#000000>$str[$fcount] </font></span></td>\n");
print("</tr>");
}
}
}