/[LeafOK_CVS]/fenglin/lib/str_process.inc.php
ViewVC logotype

Diff of /fenglin/lib/str_process.inc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 by sysadm, Fri Jun 25 08:58:04 2004 UTC Revision 1.4 by sysadm, Mon Jun 28 22:55:35 2004 UTC
# Line 1  Line 1 
1  <?  <?
2    
3  function split_line($str,$pre="",$width=75)  function split_line($str,$prefix="",$width=75)
4  {  {
5          $lines = array();          $lines = array();
6          $lines_count = 0;          $lines_count = 0;
7          $len = strlen($str);          $len = strlen($str);
8    
9          $hz_ok = true;          $hz_ok = true;
         $en_ok = true;  
10                    
11          if ($width<=0)          if ($width<=0)
12                  return $str;                  return $str;
13                    
14          $line = $pre;          $line = $prefix;
15          $line_count = strlen($line);          $line_count = strlen($line);
16          for($i=0;$i<$len;$i++)          for($i=0;$i<$len;$i++)
17          {          {
# Line 21  function split_line($str,$pre="",$width= Line 20  function split_line($str,$pre="",$width=
20                  if (ord($str[$i])>127)                  if (ord($str[$i])>127)
21                  {                  {
22                          $hz_ok = (!$hz_ok);                          $hz_ok = (!$hz_ok);
                         $en_ok = true;  
23                  }                  }
24                  if (ord($str[$i])<=127)                  if (ord($str[$i])<=127)
25                  {                  {
26                          $hz_ok = true;                          $hz_ok = true;
                         if ($str[$i] == " ")  
                         {  
                                 $en_ok = true;  
                         }  
                         else  
                         {  
                                 $en_ok = false;  
                         }  
27                  }                  }
28                  if ($line_count >= $width && $hz_ok && $en_ok)                  if ($line_count >= $width && $hz_ok)
29                  {                  {
30                          $lines[$lines_count++] = $line;                          $lines[$lines_count++] = $line;
31                          $line = $pre;                          $line = $prefix;
32                          $line_count = strlen($line);                          $line_count = strlen($line);
33                  }                  }
34          }          }
# Line 52  function split_line($str,$pre="",$width= Line 42  function split_line($str,$pre="",$width=
42          return $result;          return $result;
43  }  }
44    
45  function str_process($str,$pre="",$width=75)  function str_process($str,$prefix="",$width=75)
46  {  {
47          $result = "";          $result = "";
48                    
# Line 60  function str_process($str,$pre="",$width Line 50  function str_process($str,$pre="",$width
50    
51          foreach($lines as $line)          foreach($lines as $line)
52          {          {
53                  $result .= split_line($line,$pre,$width);                  $result .= split_line($line,$prefix,$width);
54          }          }
55                    
56          return $result;          return $result;


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1