--- fenglin/lib/str_process.inc.php 2004/06/25 08:26:49 1.2 +++ fenglin/lib/str_process.inc.php 2004/06/25 08:58:04 1.3 @@ -7,6 +7,7 @@ function split_line($str,$pre="",$width= $len = strlen($str); $hz_ok = true; + $en_ok = true; if ($width<=0) return $str; @@ -15,18 +16,31 @@ function split_line($str,$pre="",$width= $line_count = strlen($line); for($i=0;$i<$len;$i++) { - if ($line_count >= $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;