docs: def to_text(string, encoding="utf-8", errors=None):
      """Force a value to a text-type.
  
      :param string: Some input that can be converted to a unicode representation.
      :type string: str or bytes unicode
      :param encoding: The encoding to use for conversions, defaults to "utf-8"
      :param encoding: str, optional
      :return: The unicode representation of the string
      :rtype: str
      """
  
      unicode_name = get_canonical_encoding_name("utf-8")
      if not errors:
          if get_canonical_encoding_name(encoding) == unicode_name:
              if six.PY3 and os.name == "nt":
                  errors = "surrogatepass"
              else:
                  errors = "surrogateescape" if six.PY3 else "ignore"
          else:
              errors = "strict"
      if issubclass(type(string), six.text_type):
          return string
      try:
          if not issubclass(type(string), six.string_types):
              if six.PY3:
                  if isinstance(string, bytes):
                      string = six.text_type(string, encoding, errors)
                  else:
                      string = six.text_type(string)
              elif hasattr(string, "__unicode__"):
                  string = six.text_type(string)
              else:
                  string = six.text_type(bytes(string), encoding, errors)
          else:
              string = string.decode(encoding, errors)
      except UnicodeDecodeError:
          string = " ".join(to_text(arg, encoding, errors) for arg in string)
      return string