public static function is_binary_data($data)
    {
        if (preg_match('!!u', $data)) {
            return false;
        }
        $characters = str_split($data);
        foreach ($characters as $character) {
            $ord_value = ord($character);
            if ($ord_value < 0x20 or $ord_value >= 0x7f) {
                return true;
            }
        }
        return false;
    }