/** * This is a unicode aware replacement for strlen() * * Uses mb_string extension if available * * @author Andreas Gohr <*****@*****.**> * @see strlen() */ static function utf8_strlen($string) { if (!defined('UTF8_NOMBSTRING') && function_exists('mb_strlen')) { return mb_strlen($string, 'utf-8'); } $uni = UTF8::utf8_to_unicode($string); return count($uni); }