wpseek.com
WordPress开发者和主题制作者的搜索引擎



_wp_is_valid_utf8_fallback › WordPress Function

Since6.9.0
已弃用n/a
› _wp_is_valid_utf8_fallback ( $bytes )
访问:
  • private
参数:
  • (string) $bytes String which might contain text encoded as UTF-8.
    Required: Yes
查看:
  • wp_is_valid_utf8()
返回:
  • (bool) Whether the provided bytes can decode as valid UTF-8.
定义在:
文档:

Fallback mechanism for safely validating UTF-8 bytes.



源码

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