mirror of
https://github.com/e107inc/e107.git
synced 2025-07-09 09:13:25 +02:00
Speed up utf-8 truncate
This commit is contained in:
@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
||||||
| $Revision: 1.12 $
|
| $Revision: 1.13 $
|
||||||
| $Date: 2007-06-06 19:28:25 $
|
| $Date: 2007-06-07 19:19:37 $
|
||||||
| $Author: e107steved $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@ -345,11 +345,11 @@ class e_parse
|
|||||||
if (CHARSET !== 'utf-8') return substr($text,0,$len).$more; // Non-utf-8 - one byte per character - simple
|
if (CHARSET !== 'utf-8') return substr($text,0,$len).$more; // Non-utf-8 - one byte per character - simple
|
||||||
|
|
||||||
// Its a utf-8 string here - don't know whether its longer than allowed length yet
|
// Its a utf-8 string here - don't know whether its longer than allowed length yet
|
||||||
$ret = preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,0}'.
|
preg_match('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,0}'.
|
||||||
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
|
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'})(.{0,1}).*#s',$text,$matches);
|
||||||
'$1',$text);
|
|
||||||
// Now check the final length - need to count characters rather than bytes
|
$ret = $matches[1];
|
||||||
if (preg_match_all('/[\x00-\x7F\xC0-\xFD]/', $ret, $dummy) > $len) $ret .= $more;
|
if (!empty($matches[2])) $ret .= $more;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user