code: def smart_decode(binary, errors="strict"):
      
      d = chardet.detect(binary)
      encoding = d["encoding"]
      confidence = d["confidence"]
  
      text = binary.decode(encoding, errors=errors)
      return text, encoding, confidence
docs: 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