def read_char_array(self, max_length): size = self.read_int(bit_count(max_length)) self._bits = BitStream() result = self._bytes[:size] self._bytes = self._bytes[size:] return result
def write_char_array(self, max_length, value): self.write_int(bit_count(max_length), len(value)) if self._bits.len > 0: more = 8 - self._bits.len tail = (BitStream(int=0, length=more) + self._bits).tobytes() self._bits = BitStream() self._bytes += tail self._bytes += value