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

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


Description Description


Parameters Parameters

$str

(Required) String to be measured.

$enc

(Optional) Encoding type. Ignored.

Default value: ''


Top ↑

Return Return

(int) String length.


Top ↑

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

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.