--- fenglin/lib/str_process.inc.php 2004/06/25 08:58:04 1.3 +++ fenglin/lib/str_process.inc.php 2004/12/10 15:54:32 1.5 @@ -1,18 +1,17 @@ 127) { $hz_ok = (!$hz_ok); - $en_ok = true; } if (ord($str[$i])<=127) { $hz_ok = true; - if ($str[$i] == " ") - { - $en_ok = true; - } - else - { - $en_ok = false; - } } - if ($line_count >= $width && $hz_ok && $en_ok) + if ($line_count >= $width && $hz_ok) { $lines[$lines_count++] = $line; - $line = $pre; + $line = $prefix; $line_count = strlen($line); } } @@ -52,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 = ""; @@ -60,10 +50,26 @@ function str_process($str,$pre="",$width foreach($lines as $line) { - $result .= split_line($line,$pre,$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 $line) + { + $result .= ($line."\r\n"); + $l += (strlen($line)/256 + 1); + if ($l >= $max_line) + break; + } + + return $result; +} + ?>