def read_string(buffer, offset):
 length = int_struct.unpack_from(buffer, offset)[0]
 offset += int_struct.size
 if (length < 0):
  return (None, offset)
 else:
  index = offset
  offset += length
  return (buffer[index:(index + length)].decode('utf-8'), offset)

def read_string ( buffer , offset ) : length = int_struct . unpack_from ( buffer , offset ) [ 0 ] offset += int_struct . size if ( length < 0 ) : return ( None , offset ) else : index = offset offset += length return ( buffer [ index : ( index + length ) ] . decode ( 'utf-8' ) , offset )
reads an int specified buffer into a string and returns the string and the new offset in the buffer .