Tests whether a string contains only 7-bit ASCII bytes. This is used to determine when to use native functions or UTF-8 functions.
$ascii = UTF8::is_ascii($str);
boolean Core_UTF8::is_ascii( mixed $str )
参数列表
参数 类型 描述 默认值 $str
mixed
String or array of strings to check
boolean
public static function is_ascii($str)
{
if ( is_array($str) )
{
$str = implode($str);
}
return !preg_match('/[^\x00-\x7F]/S', $str);
}