def _unpack(read):
    """Decodes the unsigned integer by UTF-7 from the buffer."""
    num = 0
    shift = 0
    byte = 128
    while byte & 128:
        try:
            byte = ord(read(1))
        except TypeError:
            raise IOError('Buffer empty')
        num |= (byte & 127) << shift
        shift += 7
    return num
