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

	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.