WordPress at a glance
function is not described

wpdb::check_ascii() protected WP 4.2.0

Checks if a string is ASCII.

The negative regex is faster for non-ASCII strings, as it allows the search to finish as soon as it encounters a non-ASCII character.

{} It's a method of the class: wpdb{}

No Hooks.

Return

true/false. True if ASCII, false if not.

Usage

// protected - for code of main (parent) or child class
$result = $this->check_ascii( $string );
$string(string) (required)
String to check.

Changelog

Since 4.2.0 Introduced.

Code of wpdb::check_ascii() WP 5.5.1

<?php
protected function check_ascii( $string ) {
	if ( function_exists( 'mb_check_encoding' ) ) {
		if ( mb_check_encoding( $string, 'ASCII' ) ) {
			return true;
		}
	} elseif ( ! preg_match( '/[^\x00-\x7F]/', $string ) ) {
		return true;
	}

	return false;
}