src/helpers/StringHelper.php
public static function isUtf8String(string $string): bool
    {
        // Keep calm. Just `mb_check_encoding($string, 'UTF-8')` sucks
        // PCRE `/u` is about 10 times faster.
        // https://3v4l.org/XYQ2A

        if (false !== \preg_match('/\\G/u', $string)) {
            return true;
        }
        if (\PREG_BAD_UTF8_ERROR === \preg_last_error()) {
            return false;
        }
        throw new \LogicException('Another unexpected failure happened with PCRE');
    }
public static function isUtf8String(string $string): bool
    {
        // Keep calm. Just `mb_check_encoding($string, 'UTF-8')` sucks
        // PCRE `/u` is about 10 times faster.
        // https://3v4l.org/XYQ2A

        if (false !== \preg_match('/\\G/u', $string)) {
            return true;
        }
        if (\PREG_BAD_UTF8_ERROR === \preg_last_error()) {
            return false;
        }
        throw new \LogicException('Another unexpected failure happened with PCRE');
    }
public static function isUtf8String ( string $ string ) : bool { // Keep calm. Just `mb_check_encoding($string, 'UTF-8')` sucks // PCRE `/u` is about 10 times faster. // https://3v4l.org/XYQ2A if ( false !== \ preg_match ( '/\\G/u' , $ string ) ) { return true ; } if ( \ PREG_BAD_UTF8_ERROR === \ preg_last_error ( ) ) { return false ; } throw new \ LogicException ( 'Another unexpected failure happened with PCRE' ) ; }
Checks if a string is valid UTF-8 string
@param string $string Input string to test
@return bool Whether the input string is valid UTF-8 data
Checks if a string is valid UTF - 8 string