Share several useful PHP string truncation functions (gb2312 and UTF-8 supported ).
<? mysubstr(, , = "" = + ( = 0; < ; ++(((, , 1)) > 0xa0 .= (, , 2++ .= (, , 1 ?>
<? utf8Substr(, , ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'..'}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'..'}).*#s', '$1',?>
<? Cut_str (, = 0, = 'utf-8' (= 'utf-8' = "/[\ x01-\ x7f] | [\ xc2-\ xdf] [\ x80-\ xbf] | \ xe0 [\ xa0-\ xbf] [\ x80-\ xbf] | [\ xe1-\ xef] [\ x80-\ xbf] [\ x80-\ xbf] | \ xf0 [\ x90-\ xbf] [\ x80-\ xbf] [\ x80-\ xbf] | [\ xf1-\ xf7] [\ x80-\ xbf] [\ x80 -\ xbf] [\ x80-\ xbf]/"(, ([0])->) ('', ([0],). "... "('', ([0], = * 2 = * 2 = (= ''(= 0; <; ++ (>=& & <(+ (, 1)> 129. = (, 2. = (, 1 (, 1)> 129) ++ () <). = "... "=" abcd string to be intercepted "c Ut_str (, 8, 0, 'gb2312'?>
<? SysSubStr (, = () <= 0 (<= (, 1 ()> = 224 = (, 3 = + 3 ()> = 192 = (, 2 = + 2 = + 1 [] = ("",(. = "... "=" book.chinaz.com -- webmasters library and webmasters tutorial "=" 18 "= sysSubStr (,?>