Reads a variable-length NUL-terminated string as defined in SOCKS4.
551959
private static String readString(String fieldName, ByteBuf in) {
        int length = in.bytesBefore(MAX_FIELD_LENGTH + 1, (byte) 0);
        if (length < 0) {
            throw new DecoderException("field '" + fieldName + "' longer than " + MAX_FIELD_LENGTH + " chars");
        }

        String value = in.readSlice(length).toString(CharsetUtil.US_ASCII);
        in.skipBytes(1); // Skip the NUL.

        return value;
    }
1271275
public String readString(int length) {
        log.debug("readString - length: {}", length);
        int limit = buf.limit();
        final ByteBuffer strBuf = buf.buf();
        strBuf.limit(strBuf.position() + length);
        final String string = AMF.CHARSET.decode(strBuf).toString();
        log.debug("String: {}", string);
        buf.limit(limit);
        // check for null termination
        byte b = buf.get();
        if (b != 0) {
            buf.position(buf.position() - 1);
        }
        return string;
    }
330337
function readVarInt (buffer, offset) {
  const result = varuint.decode(buffer, offset);

  return {
    number: result,
    size: varuint.decode.bytes
  };
}
1164480
@Override
  public <T extends BinaryReadHandle> T read(String uri, T contentHandle, long start, long length) {
    return read(uri, null, contentHandle, null, start, length, null);
  }
1262963
def _get_string(data, position, obj_end, dummy):
    """"""
    length = _UNPACK_INT(data[position:position + 4])[0]
    position += 4
    if length < 1 or obj_end - position < length:
        raise InvalidBSON("invalid string length")
    end = position + length - 1
    if data[end:end + 1] != b"\x00":
        raise InvalidBSON("invalid end of string")
    return _utf_8_decode(data[position:end], None, True)[0], end + 1
507917
def read(read_len)
      # If we closed the connection, return nil without calling anything again to avoid EOF
      # or other errors
      return nil if @closed

      if @left_to_read
        # We hit the end of what we need to read, if this is a chunked request, then we need to check for the next chunk
        if @left_to_read <= read_len
          data = @socket.read(@left_to_read)
          @total_size += @left_to_read
          @left_to_read = nil
          @read_clfr = true
        # Reading from known buffer still
        else
          @left_to_read -= read_len
          @total_size += read_len
          data = @socket.read(read_len)
        end

      elsif @chunked
        # We finished reading the chunks, read the last 2 to get \r\n out of the way, and then find the next chunk
        if @read_clfr
          @read_clfr = nil
          @socket.read(2)
        end

        data, chunk_read = "", 0
        while true
          # Read first line to get the chunk length
          line = @socket.readline

          len = line.slice(/[0-9a-fA-F]+/) or raise Net::HTTPBadResponse.new("wrong chunk size line: #{line}")
          len = len.hex

          # Nothing left, read off the final \r\n
          if len == 0
            @socket.read(2)
            @socket.close
            @response.instance_variable_set(:@read, true)

            @closed = true
            break
          end

          # Reading this chunk will set us over the buffer amount
          # Read what we can of it (if anything), and send back what we have and queue a read for the rest
          if ( chunk_read + len ) > read_len
            can_read = len - ( ( chunk_read + len ) - read_len )

            @left_to_read = len - can_read
            @total_size += can_read

            data << @socket.read(can_read) if can_read > 0
            break
          # We can just return the chunk as-is
          else
            @total_size += len
            chunk_read += len

            data << @socket.read(len)
            @socket.read(2)
          end
        end

      # If we don't have a content length, then we need to keep reading until we run out of data
      elsif !@content_length
        data = @socket.readline

        @total_size += data.length if data
      end

      # We've finished reading, set this so Net::HTTP doesn't try and read it again
      if !data or data == ""
        @response.instance_variable_set(:@read, true)

        nil
      else
        if data.length >= @total_size and !@chunked
          @response.instance_variable_set(:@read, true)
        end

        if ENCODABLE and @encoding
          data = data.force_encoding(@encoding) if @encoding
          data = data.encode("UTF-8")
        end

        @digest.update(data)
        data
      end

    # Mark as read finished, return the last bits of data (if any)
    rescue EOFError
      @response.instance_variable_set(:@read, true)
      @socket.close
      @closed = true

      if data and data != ""
        @digest.update(data)
        data
      else
        nil
      end
    end
675018
private function read()
    {
        $s = null;

        for (; !feof($this->sock);) {
            if (($line = fgets($this->sock, 1e3)) == null) {
                continue;
            }

            $s = explode(' ', $line)[0];

            if (preg_match('#^[0-9]+$#', $s)) {
                break;
            }
        }

        return (int) $s;
    }
350617
def read(self, length):
        
        data = bytearray()
        while len(data) != length:
            data += self.sock.recv((length - len(data)))
            if not data:
                raise ConnectionError('Connection unexpectedly closed.')
        return data
213457
def ansi_len(string):
    """"""
    return len(string) - wcswidth(re.compile(r'\x1b[^m]*m').sub('', string))
51562
def read_c_string( self ):
        
        rval = []
        while 1:
            ch = self.file.read(1)
            assert len( ch ) == 1, "Unexpected end of file"
            if ch == b'\0':
                break
            rval.append( ch )
        return b''.join( rval )
1189836
private static int readShortLength(DataInput in) throws IOException {
        int length = (in.readByte() & 0xFF) << 8;
        return length | (in.readByte() & 0xFF);
    }
684082
def ReadLsbBytes(rd, offset, value_size):
  """"""

  encoding = None
  if value_size == 1:
    encoding = '<B'
  elif value_size == 2:
    encoding = '<H'
  elif value_size == 4:
    encoding = '<L'
  else:
    raise errors.HidError('Invalid value size specified')

  ret, = struct.unpack(encoding, rd[offset:offset + value_size])
  return ret
409122
def read(self, n=-1):
        
        if n is None or n < 0:
            buf = self._readbuffer[self._offset:]
            self._readbuffer = b''
            self._offset = 0
            while not self._eof:
                buf += self._read1(self.MAX_N)
            return buf

        end = n + self._offset
        if end < len(self._readbuffer):
            buf = self._readbuffer[self._offset:end]
            self._offset = end
            return buf

        n = end - len(self._readbuffer)
        buf = self._readbuffer[self._offset:]
        self._readbuffer = b''
        self._offset = 0
        while n > 0 and not self._eof:
            data = self._read1(n)
            if n < len(data):
                self._readbuffer = data
                self._offset = n
                buf += data[:n]
                break
            buf += data
            n -= len(data)
        return buf
1354729
public String readStringNullEnd(final Charset charset) {
    int initialPosition = position;
    int cnt = 0;
    while (remaining() > 0 && (buf[position++] != 0)) {
      cnt++;
    }
    return new String(buf, initialPosition, cnt, charset);
  }
100366
def read(self, len):
        
        ret = libxml2mod.xmlParserInputBufferRead(self._o, len)
        return ret
640338
def read(sock, count):
    
    data = None

    try:
        data = sock.recv(count)
    except ssl.SSLError as e:
        return data, e.errno, e.strerror if strerror else e.message
    except socket.herror as (errnum, errmsg):
        return data, errnum, errmsg
    except socket.gaierror as (errnum, errmsg):
        return data, errnum, errmsg
    except socket.timeout:
        return data, errno.ETIMEDOUT, "Connection timed out"
    except socket.error as (errnum, errmsg):
        return data, errnum, errmsg
    
    ba_data = bytearray(data)
    
    if len(ba_data) == 0:
        return ba_data, errno.ECONNRESET, "Connection closed"
    
    return ba_data, 0, ""
263119
def _read(self, n):
        
        while len(self._read_buffer) < n:
            s = self.sock.recv(65536)
            if not s:
                raise IOError('Socket closed')
            self._read_buffer += s

        result = self._read_buffer[:n]
        self._read_buffer = self._read_buffer[n:]

        return result