(self, ba)
return True, state == Utf8Validator.UTF8_ACCEPT, i, self.i
Incrementally validate a chunk of bytes provided as bytearray.

        Will return a quad (valid?, endsOnCodePoint?, currentIndex, totalIndex).

        As soon as an octet is encountered which renders the octet sequence
        invalid, a quad with valid? == False is returned. currentIndex returns
        the index within the currently consumed chunk, and totalIndex the
        index within the total consumed sequence that was the point of bail out.
        When valid? == True, currentIndex will be len(ba) and totalIndex the
        total amount of consumed bytes.
Incrementally validate a chunk of bytes provided as bytearray.
Incrementally validate a chunk of bytes provided as bytearray .
def validate(self, ba):
        """
        Incrementally validate a chunk of bytes provided as bytearray.

        Will return a quad (valid?, endsOnCodePoint?, currentIndex, totalIndex).

        As soon as an octet is encountered which renders the octet sequence
        invalid, a quad with valid? == False is returned. currentIndex returns
        the index within the currently consumed chunk, and totalIndex the
        index within the total consumed sequence that was the point of bail out.
        When valid? == True, currentIndex will be len(ba) and totalIndex the
        total amount of consumed bytes.
        """
        state = self.state
        DFA = Utf8Validator.UTF8VALIDATOR_DFA
        i = 0  # make sure 'i' is set if when 'ba' is empty
        for i, b in enumerate(ba):
            ## optimized version of decode(), since we are not interested in actual code points
            state = DFA[256 + (state << 4) + DFA[b]]
            if state == Utf8Validator.UTF8_REJECT:
                self.i += i
                self.state = state
                return False, False, i, self.i
        self.i += i
        self.state = state
        return True, state == Utf8Validator.UTF8_ACCEPT, i, self.i
def validate ( self , ba ) : state = self . state DFA = Utf8Validator . UTF8VALIDATOR_DFA i = 0 # make sure 'i' is set if when 'ba' is empty for i , b in enumerate ( ba ) : ## optimized version of decode(), since we are not interested in actual code points state = DFA [ 256 + ( state << 4 ) + DFA [ b ] ] if state == Utf8Validator . UTF8_REJECT : self . i += i self . state = state return False , False , i , self . i self . i += i self . state = state return True , state == Utf8Validator . UTF8_ACCEPT , i , self . i