Logo Search packages:      
Sourcecode: radicale version File versions  Download package

def radicale::CalendarHTTPHandler::_decode (   self,
  text 
) [private]
Try to decode text according to various parameters.

Definition at line 125 of file __init__.py.

                           :
        """Try to decode text according to various parameters."""
        # List of charsets to try
        charsets = []

        # First append content charset given in the request
        content_type = self.headers.get("Content-Type", None)
        if content_type and "charset=" in content_type:
            charsets.append(content_type.split("charset=")[1].strip())
        # Then append default Radicale charset
        charsets.append(self._encoding)
        # Then append various fallbacks
        charsets.append("utf-8")
        charsets.append("iso8859-1")

        # Try to decode
        for charset in charsets:
            try:
                return text.decode(charset)
            except UnicodeDecodeError:
                pass
        raise UnicodeDecodeError


Generated by  Doxygen 1.6.0   Back to index