mb_strlen( string $str, string $enc = '' )

Fallback implementation of mb_strlen(), hardcoded to UTF-8.

Description

Parameters

$str

(Required) String to be measured.

$enc

(Optional) Encoding type. Ignored.

Default value: ''

Return

(int) String length.

Source

File: bp-core/bp-core-wpabstraction.php

244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
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;
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.