--- fenglin/lib/str_process.inc.php 2004/06/25 06:49:15 1.1 +++ fenglin/lib/str_process.inc.php 2004/06/25 08:58:04 1.3 @@ -1,12 +1,13 @@ = $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); + $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) + { + $lines[$lines_count++] = $line; + $line = $pre; + $line_count = strlen($line); + } } $lines[$lines_count++] = $line; @@ -38,7 +52,7 @@ function split_line($str,$width=75,$pre= return $result; } -function add_colon($str,$width=75) +function str_process($str,$pre="",$width=75) { $result = ""; @@ -46,7 +60,7 @@ function add_colon($str,$width=75) foreach($lines as $line) { - $result .= split_line($line,$width,": "); + $result .= split_line($line,$pre,$width); } return $result;