Code snippets from amqplib 0.6.1:
def read_shortstr(self): """ Read a utf-8 encoded string that's stored in up to 255 bytes. Return it decoded as a Python unicode object. """ self.bitcount = self.bits = 0 slen = unpack('B', self.input.read(1))[0] return self.input.read(slen).decode('utf-8') def read_longstr(self): """ Read a string that's up to 2**32 bytes, the encoding isn't specified in the AMQP spec, so just return it as a plain Python string. """ self.bitcount = self.bits = 0 slen = unpack('>I', self.input.read(4))[0] return self.input.read(slen)
No comments:
Post a Comment