Beispiel #1
0
def lookupEncoding(encoding):
    """Return the python codec name corresponding to an encoding or None if the

    string doesn't correspond to a valid encoding."""

    if isinstance(encoding, bytes):

        try:

            encoding = encoding.decode("ascii")

        except UnicodeDecodeError:

            return None

    if encoding is not None:

        try:

            return webencodings.lookup(encoding)

        except AttributeError:

            return None

    else:

        return None
Beispiel #2
0
def lookupEncoding(encoding):
    """Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding."""
    if isinstance(encoding, binary_type):
        try:
            encoding = encoding.decode("ascii")
        except UnicodeDecodeError:
            return None

    if encoding is not None:
        try:
            return webencodings.lookup(encoding)
        except AttributeError:
            return None
    else:
        return None
Beispiel #3
0
                try:
                    self.data.skipUntil(spaceCharactersBytes)
                    return self.data[oldPosition:self.data.position]
                except StopIteration:
                    # Return the whole remaining value
                    return self.data[oldPosition:]
        except StopIteration:
            return None


def lookupEncoding(encoding):
    """Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding."""
<<<<<<< HEAD
    if isinstance(encoding, binary_type):
=======
    if isinstance(encoding, bytes):
>>>>>>> 7e5c5fbd6c824de4d4c2b62da3f7cae87d462119
        try:
            encoding = encoding.decode("ascii")
        except UnicodeDecodeError:
            return None

    if encoding is not None:
        try:
            return webencodings.lookup(encoding)
        except AttributeError:
            return None
    else:
        return None