read a string of bytes representing an indefinite length object.
169174
private byte[] readIndefiniteLengthFully()
        throws IOException
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        int                     b, b1;

        b1 = read();

        while ((b = read()) >= 0)
        {
            if (b1 == 0 && b == 0)
            {
                break;
            }

            bOut.write(b1);
            b1 = b;
        }

        return bOut.toByteArray();
    }
1299548
def read_utf8_string(self, length):
        
        s = struct.unpack("%s%ds" % (self.endian, length), self.read(length))[0]

        return s.decode('utf-8')
550816
private static int readStringLength(DataInputView source) throws IOException {
		int len = source.readByte() & 0xFF;

		if (len >= HIGH_BIT) {
			int shift = 7;
			int curr;
			len = len & 0x7F;
			while ((curr = source.readByte() & 0xFF) >= HIGH_BIT) {
				len |= (curr & 0x7F) << shift;
				shift += 7;
			}
			len |= curr << shift;
		}

		return len;
	}
475732
def read_str(self):
        
        length = self.read_uint8()
        return self.unpack(str(length) + 's', length)
1252618
def read(self, n):
        ''''''
        bytes_wanted = n - self.buffer_length + self.pos + 1
        if bytes_wanted > 0:
            self._buffer_bytes(bytes_wanted)

        end_pos = self.pos + n
        ret = self.buffer[self.pos + 1:end_pos + 1]
        self.pos = end_pos
        return ret
1120259
public int readLength() throws IOException {
		int length = 0;

		byte b = (byte) this.read();

		// This is short form. The short form can be used if the number of
		// octets in the Value part is less than or
		// equal to 127, and can be used whether the Value part is primitive or
		// constructed. This form is identified by
		// encoding bit 8 as zero, with the length count in bits 7 to 1 (as
		// usual, with bit 7 the most significant bit
		// of the length).
		if ((b & 0x80) == 0) {
			return b;
		}

		// This is indefinite form. The indefinite form of length can only be
		// used (but does not have to be) if the V
		// part is constructed, that
		// is to say, consists of a series of TLVs. In the indefinite form of
		// length the first bit of the first octet is
		// set to 1, as for the long form, but the value N is set to zero.
		b = (byte) (b & 0x7F);
		if (b == 0) {
			return Tag.Indefinite_Length;
		}

		// If bit 8 of the first length octet is set to 1, then we have the long
		// form of length. In long form, the first
		// octet encodes in its remaining seven bits a value N which is the
		// length of a series of octets that themselves
		// encode the length of the Value part.
		byte temp;
		for (int i = 0; i < b; i++) {
			temp = (byte) this.read();
			length = (length << 8) | (0x00FF & temp);
		}

		return length;
	}
1122547
def _read_byte(self):
        """"""

        to_return = ""
        if (self._mode == PROP_MODE_SERIAL):
            to_return = self._serial.read(1)
        elif (self._mode == PROP_MODE_TCP):
            to_return = self._socket.recv(1)
        elif (self._mode == PROP_MODE_FILE):
            to_return = struct.pack("B", int(self._file.readline()))

        _LOGGER.debug("READ: " + str(ord(to_return)))
        self._logdata.append(ord(to_return))
        if (len(self._logdata) > self._logdatalen):
            self._logdata = self._logdata[len(self._logdata) - self._logdatalen:]

        self._debug(PROP_LOGLEVEL_TRACE, "READ: " + str(ord(to_return)))

        return to_return
803665
def read_long(self):
        """"""
        self.bitcount = self.bits = 0
        return unpack('>I', self.input.read(4))[0]
680004
def read_raw(self, length, *, error=None):
        """"""
        if length is None:
            length = len(self)

        raw = dict(
            packet=self._read_fileng(length),
            error=error or None,
        )

        return raw
130202
def readString(self):
        
        resultStr = ""
        while self.data[self.offset] != "\x00":
            resultStr += self.data[self.offset]
            self.offset += 1
        return resultStr
169599
def read(self, length, skip=False):
        """"""
        if length > self.__size:
            raise IndexError(
                'Cannot pop %d bytes, %d bytes in buffer queue' % (length, self.__size))
        self.position += length
        self.__size -= length
        segments = self.__segments
        offset = self.__offset

        data = self.__data_cls()
        while length > 0:
            segment = segments[0]
            segment_off = offset
            segment_len = len(segment)
            segment_rem = segment_len - segment_off
            segment_read_len = min(segment_rem, length)

            if segment_off == 0 and segment_read_len == segment_rem:
                # consume an entire segment
                if skip:
                    segment_slice = self.__element_type()
                else:
                    segment_slice = segment
            else:
                # Consume a part of the segment.
                if skip:
                    segment_slice = self.__element_type()
                else:
                    segment_slice = segment[segment_off:segment_off + segment_read_len]
                offset = 0
            segment_off += segment_read_len
            if segment_off == segment_len:
                segments.popleft()
                self.__offset = 0
            else:
                self.__offset = segment_off

            if length <= segment_rem and len(data) == 0:
                return segment_slice
            data.extend(segment_slice)
            length -= segment_read_len
        if self.is_unicode:
            return data.as_text()
        else:
            return data
190034
def str2bytes(x):
  """"""
  if type(x) is bytes:
    return x
  elif type(x) is str:
    return bytes([ ord(i) for i in x ])
  else:
    return str2bytes(str(x))
11819
def _readintbe(self, length, start):
        """"""
        if length % 8:
            raise InterpretError("Big-endian integers must be whole-byte. "
                                 "Length = {0} bits.", length)
        return self._readint(length, start)
1177814
def _read_stream_for_size(stream, buf_size=65536):
    """"""
    size = 0
    while True:
        buf = stream.read(buf_size)
        size += len(buf)
        if not buf:
            break
    return size
693999
def readBuffer(self, newLength):
        
        result = Buffer(self.buf, self.offset, newLength)
        self.skip(newLength)
        return result
1081699
def read_plain_int32(file_obj, count):
    """"""
    length = 4 * count
    data = file_obj.read(length)
    if len(data) != length:
        raise EOFError("Expected {} bytes but got {} bytes".format(length, len(data)))
    res = struct.unpack("<{}i".format(count).encode("utf-8"), data)
    return res
501455
def read_bytes(self, count):
        
        result = self.input.read(count)
        found = len(result)
        self.lineno += result.count(b'\n')
        if found != count:
            self.abort(errors.MissingBytes, count, found)
        return result