_wp_has_noncharacters_fallback()WP 6.9.0

Fallback support for determining if a string contains Unicode noncharacters.

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

true|false. Whether noncharacters were found in the string.

Usage

_wp_has_noncharacters_fallback( $text ): bool;
$text(string) (required)
Are there noncharacters in this string?.

Notes

  • See: [wp_has_noncharacters()](/function/wp_has_noncharacters)

Changelog

Since 6.9.0 Introduced.

_wp_has_noncharacters_fallback() code WP 6.9.1

function _wp_has_noncharacters_fallback( string $text ): bool {
	$at                = 0;
	$invalid_length    = 0;
	$has_noncharacters = false;
	$end               = strlen( $text );

	while ( $at < $end && ! $has_noncharacters ) {
		_wp_scan_utf8( $text, $at, $invalid_length, null, null, $has_noncharacters );
		$at += $invalid_length;
	}

	return $has_noncharacters;
}