Automatically find the right codec to decode binary data to string.

    :param binary: binary data
    :param errors: one of 'strict', 'ignore' and 'replace'
    :return: string

def smart_decode(binary, errors="strict"):
    """
    Automatically find the right codec to decode binary data to string.

    :param binary: binary data
    :param errors: one of 'strict', 'ignore' and 'replace'
    :return: string
    """
    d = chardet.detect(binary)
    encoding = d["encoding"]
    confidence = d["confidence"]

    text = binary.decode(encoding, errors=errors)
    return text, encoding, confidence