diff options
author | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-23 10:20:50 +0000 |
---|---|---|
committer | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-23 10:20:50 +0000 |
commit | 3c5cbd014bb23c77129dea9d30a6f592289b5572 (patch) | |
tree | aec074f3ce0908d7bffcb960428c5b628fbe6808 /functions | |
parent | 4a6873ff761aeb775cf57ed30e13dbf6caf64b4d (diff) | |
download | phpicalendar-3c5cbd014bb23c77129dea9d30a6f592289b5572.tar.gz phpicalendar-3c5cbd014bb23c77129dea9d30a6f592289b5572.tar.bz2 phpicalendar-3c5cbd014bb23c77129dea9d30a6f592289b5572.zip |
bug fixes from tracker
Diffstat (limited to 'functions')
-rw-r--r-- | functions/draw_functions.php | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/functions/draw_functions.php b/functions/draw_functions.php index cc1c363..a5a98a9 100644 --- a/functions/draw_functions.php +++ b/functions/draw_functions.php @@ -40,8 +40,36 @@ function drawEventTimes ($start, $end) { function word_wrap($str, $length, $lines=0) { if ($lines > 0) { $len = $length * $lines; - if ($len < strlen($str)) { - $str = substr($str,0,$len).'...'; + //if ($len < strlen($str)) { + // $str = substr($str,0,$len).'...'; + //} + $rstr=bite_str($str,0,$len+1); + } + return $rstr; +} + +// String intercept By Bleakwind +// utf-8:$byte=3 | gb2312:$byte=2 | big5:$byte=2 +function bite_str($string, $start, $len, $byte=3){ + $str = ""; + $count = 0; + $str_len = strlen($string); + for ($i=0; $i<$str_len; $i++) { + if (($count+1-$start)>$len) { + $str .= "..."; + break; + } elseif ((ord(substr($string,$i,1)) <= 128) && ($count < $start)){ + $count++; + } elseif ((ord(substr($string,$i,1)) > 128) && ($count < $start)){ + $count = $count+2; + $i = $i+$byte-1; + } elseif ((ord(substr($string,$i,1)) <= 128) && ($count >= $start)){ + $str .= substr($string,$i,1); + $count++; + } elseif ((ord(substr($string,$i,1)) > 128) && ($count >= $start)){ + $str .= substr($string,$i,$byte); + $count = $count+2; + $i = $i+$byte-1; } } return $str; |