(just remember that it's 1.5 to 5 times slower, like I said earlier. Whether or not that's an issue will have to be decided by higher powers)
On Aug 3, 2010, at 5:54 PM, Aryeh Gregor wrote:
On Tue, Aug 3, 2010 at 5:09 PM, Daniel Friesen lists@nadir-seen-fire.com wrote:
Yup, though we might as well remember that not everyone has mb_ functions installed.
if ( !function_exists( 'mb_strlen' ) ) { /** * Fallback implementation of mb_strlen, hardcoded to UTF-8. * @param string $str * @param string $enc optional encoding; ignored * @return int */ function mb_strlen( $str, $enc="" ) { $counts = count_chars( $str ); $total = 0;
// Count ASCII bytes for( $i = 0; $i < 0x80; $i++ ) { $total += $counts[$i]; } // Count multibyte sequence heads for( $i = 0xc0; $i < 0xff; $i++ ) { $total += $counts[$i]; } return $total; }
}
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l