--- fenglin/lib/str_process.inc.php 2004/06/25 08:26:49 1.2 +++ fenglin/lib/str_process.inc.php 2005/03/12 08:01:19 1.6 @@ -1,6 +1,6 @@ = $width && $hz_ok) - { - $lines[$lines_count++] = $line; - $line = $pre; - $line_count = strlen($line); - } $line.=$str[$i]; $line_count++; if (ord($str[$i])>127) + { $hz_ok = (!$hz_ok); + } if (ord($str[$i])<=127) + { $hz_ok = true; + } + if ($line_count >= $width && $hz_ok) + { + $lines[$lines_count++] = $line; + $line = $prefix; + $line_count = strlen($line); + } } $lines[$lines_count++] = $line; @@ -38,7 +42,7 @@ function split_line($str,$pre="",$width= return $result; } -function str_process($str,$pre="",$width=75) +function str_process($str,$prefix="",$width=75) { $result = ""; @@ -46,10 +50,26 @@ function str_process($str,$pre="",$width foreach($lines as $line) { - $result .= split_line($line,$pre,$width); + $result .= split_line($line[0],$prefix,$width); } return $result; } +function str_b_lines($str,$max_line=1) +{ + $result = ""; + $l = 0; + $lines = explode("\n",str_replace("\r\n","\n",$str)); + foreach($lines as $line) + { + $result .= ($line[0]."\r\n"); + $l += (strlen($line[0])/256 + 1); + if ($l >= $max_line) + break; + } + + return $result; +} + ?>