src/Debug/Utf8.php
public static function isUtf8($str, &$special = false)
    {
        self::setStr($str);
        $special = false;
        while (self::$curI < self::$stats['strLen']) {
            $isUtf8 = self::isOffsetUtf8($isSpecial); // special is only checking control chars
            if (!$isUtf8) {
                return false;
            }
            if ($isSpecial) {
                $special = true;
            }
        }
        $special = $special || self::hasSpecial($str);
        return true;
    }
public static function isUtf8($str, &$special = false)
    {
        self::setStr($str);
        $special = false;
        while (self::$curI < self::$stats['strLen']) {
            $isUtf8 = self::isOffsetUtf8($isSpecial); // special is only checking control chars
            if (!$isUtf8) {
                return false;
            }
            if ($isSpecial) {
                $special = true;
            }
        }
        $special = $special || self::hasSpecial($str);
        return true;
    }
Determine if string is UTF-8 encoded

In addition, if valid UTF-8, will also report whether string contains
control, or other speical characters that could otherwise go unnoticed

@param string  $str     string to check
@param boolean $special does valid utf-8 string control or "exotic" whitespace type character

@return boolean