Change the contents of the plugins/modifier. truncate. php file
<? PHP
/*
* smarty plugin
* -----------------------------------------------------
* type: modifier
* Name: truncate
* purpose: truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and
* appending the $ etc string.
* update: Change substr to msubstr and add fun msubstr. so it
* Can Bu used in Chinese charset.
* -------------------------------------------------------------
*/
Function Smarty_modifier_truncate ( $ String , $ Length = 80 , $ Etc = ' ' ,
$ Break_words = False )
{
If ( $ Length = 0 )
Return '' ;
If ( Strlen ( $ String ) > $ Length ){
$ Length -= Strlen ( $ Etc );
If ( ! $ Break_words )
$ String = Preg_replace ( ' /\ S +? (\ S + )? $/ ' , '' , Substrgb ( $ String , 0 , $ Length + 1 ));
Return Substrgb ( $ String , 0 , $ Length ) . $ Etc ;
} Else
Return $ String ;
}
FunctionSubstrgb ($ Str,$ Start,$ Len){
For($ I=0;$ I<$ Start+$ Len;$ I++){
$ Tmpstr = ( ORD ( $ Str [ $ I ]) > = 161 && ORD ( $ Str [ $ I ]) <= 254 && ORD ( $ Str [ $ I + 1 ]) > = 161 && ORD ( $ Str [ $ I + 1 ]) <= 254 ) ? $ Str [ $ I ] . $ Str [ ++ $ I ] : $ Tmpstr = $ Str [ $ I ];
If($ I> =$ Start&&$ I<($ Start+$ Len))$ TMP . =$ Tmpstr;
}
Return $ TMP;
}
/*VIM: Set expandtab:*/
?>
Chinese characters are supported without garbled characters.