docs: def reopen_encoded(fileobj, mode='r', fallback_encoding=None):
      """Makes sure that a file was opened with some valid encoding.
  
      Arguments:
          fileobj (file): The file-object.
          mode (str, optional): The mode in which to re-open the file.
          fallback_encoding (str, optional): The encoding in which to re-open
              the file if it does not specify an encoding itself.
  
      Returns:
          file: The re-opened file.
  
      """
      encoding = determine_encoding(fileobj.name, fallback_encoding)
      fileobj.close()
      return open(fileobj.name, mode, encoding=encoding)