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; } }