_wp_utf8_codepoint_count(string$text, ?int$byte_offset = 0, ?int$max_byte_length = PHP_INT_MAX ): int
Since
6.9.0
Source
wp-includes/compat-utf8.php:341
Returns how many code points are found in the given UTF-8 string.
Description
Invalid spans of bytes count as a single code point according to the maximal subpart rule. This function is a fallback method for calling mb_strlen( $text, 'UTF-8' ). When negative values are provided for the byte offsets or length, this will always report zero code points. Example: 4 === _wp_utf8_codepoint_count( 'text' );
// Groups are 'test', "\x90" as '�', 'wp', "\xE2\x80" as '�', "\xC0" as '�', and 'test'.
13 === _wp_utf8_codepoint_count( "test\x90wp\xE2\x80\xC0test" );
Parameters
$textstring
Count code points in this string.
$byte_offset?intoptional
Start counting after this many bytes in $text. Must be positive.Default: 0
$max_byte_length?intoptional
Stop counting after having scanned past this many bytes. Default is to scan until the end of the string. Must be positive.Default: PHP_INT_MAX
Return
int
How many code points were found.
Uses · 1
_wp_scan_utf8()Finds spans of valid and invalid UTF-8 bytes in a given string.
Used by · 2
_mb_strlen()Internal compat function to mimic mb_strlen().
_mb_substr()Internal compat function to mimic mb_substr().
Signature, return type and hooks compared across 3 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/compat-utf8.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.