_wp_is_valid_utf8_fallback()
Fallback mechanism for safely validating UTF-8 bytes.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
bool. Whether the provided bytes can decode as valid UTF-8.
Usage
_wp_is_valid_utf8_fallback( $bytes ): bool;
- $bytes(string) (required)
- String which might contain text encoded as UTF-8.
Notes
| See: wp_is_valid_utf8() |
Changelog
| Since 6.9.0 | Introduced. |
_wp_is_valid_utf8_fallback() wp is valid utf8 fallback code WP 7.1
function _wp_is_valid_utf8_fallback( string $bytes ): bool {
$bytes_length = strlen( $bytes );
if ( 0 === $bytes_length ) {
return true;
}
$next_byte_at = 0;
$invalid_length = 0;
_wp_scan_utf8( $bytes, $next_byte_at, $invalid_length );
return $bytes_length === $next_byte_at && 0 === $invalid_length;
}