--- fenglin/lib/str_process.inc.php 2004/06/25 06:49:15 1.1 +++ fenglin/lib/str_process.inc.php 2005/03/23 17:31:14 1.7 @@ -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,18 +42,34 @@ function split_line($str,$width=75,$pre= return $result; } -function add_colon($str,$width=75) +function str_process($str,$prefix="",$width=75) { $result = ""; $lines = explode("\n",str_replace("\r\n","\n",$str)); - foreach($lines as $line) + foreach($lines as $tmp => $line) { - $result .= split_line($line,$width,": "); + $result .= split_line($line,$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 $tmp => $line) + { + $result .= ($line."\r\n"); + $l += (strlen($line)/256 + 1); + if ($l >= $max_line) + break; + } + + return $result; +} + ?>