Reads binary data from shared memory.

@param int $offset The offset to read from.
@param int $size   The number of bytes to read.

@return string The binary data at the given offset.
426873
private function memGet(int $offset, int $size): string
    {
        $data = \shmop_read($this->handle, $offset, $size);
        if ($data === false) {
            throw new SharedMemoryException('Failed to read from shared memory block.');
        }
        return $data;
    }
1027287
public function getByteAt($offset)
    {
        $length = \strlen($this->_string);

        if (0 > $offset) {
            $offset = -$offset % $length;

            if (0 !== $offset) {
                $offset = $length - $offset;
            }
        } elseif ($offset >= $length) {
            $offset %= $length;
        }

        return $this->_string[$offset];
    }
1170077
protected function readString($fr,$length,$offset=null)
	{
		if($offset!==null)
			fseek($fr,$offset);
		return $this->readByte($fr,$length);
	}
716174
@Override
    public byte readByte(final boolean unsigned, final int size) throws IOException {
        return (byte) readInt(unsigned, requireValidSizeByte(unsigned, size));
    }
12403
public function read($size = null)
    {
        if (feof($this->_stream)) {
            $this->close();
            $this->_params['debug']->info(
                'ERROR: Server closed the connection.'
            );
            throw new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("Server closed the connection unexpectedly."),
                Horde_Imap_Client_Exception::DISCONNECT
            );
        }

        if (($read = fgets($this->_stream)) === false) {
            $this->_params['debug']->info('ERROR: read/timeout error.');
            throw new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("Error when communicating with the mail server."),
                Horde_Imap_Client_Exception::SERVER_READERROR
            );
        }

        $this->_params['debug']->server(rtrim($read, "\r\n"));

        return $read;
    }
167622
public function read(int $size = null)
    {
        if ($this->file == null) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Cannot read file for unopened file",
                "solution" =>
                    "Please open the file with [FileListener::open] before trying to get read it.")));
        }
        if ($size === null) {
            return (fread($this->file, $this->size()));
        } else {
            return (fread($this->file, $size));
        }
    }
61868
public static function newFromBytes($size, $data)
    {
        $bstream = new QRbitstream();
        $bstream->allocate($size * 8);
        $p=0;

        for($i=0; $i<$size; $i++) {
            $mask = 0x80;
            for($j=0; $j<8; $j++) {
                if($data[$i] & $mask) {
                    $bstream->data[$p] = 1;
                } else {
                    $bstream->data[$p] = 0;
                }
                $p++;
                $mask = $mask >> 1;
            }
        }

        return $bstream;
    }
698708
protected final int readBytesAt(int offset)
        throws IOException
    {
        // shouldn't modify mBytePtr, assumed to be 'offset'
        if (mIn != null) {
            int count = mIn.read(mByteBuffer, offset, mByteBuffer.length - offset);
            if (count > 0) {
                mByteBufferEnd += count;
            }
            return count;
        }
        return -1;
    }
696460
protected function getByteSize($size)
    {
        if (! preg_match('/(\d+)\s*([tgkmbi]{1,3})/i', $size, $result)) {
            return $size;
        }

        $mapping = $this->mapping[strtolower($result[2])];
        return pow($mapping[0], $mapping[1]) * $result[1];
    }
1118231
def read(self, size=-1):
    
    if size < 0:
      offset = len(self._buffer)
    else:
      offset = self._offset + size
    return self.read_to_offset(offset)
1193005
public function readPascalString($offset = 0, $read_offset = false)
    {

        // Get the proper offset
        $len = $this->readInt8();
        $offset = max($len - $offset, 0);

        // Read the data
        if ($read_offset) {
            return $this->read($offset);
        } else {
            return substr($this->read($len), 0, $offset);
        }
    }
1371518
public function read(int $length = 1, int $offset = 0) : string
    {
        return substr($this->getContent(), $offset, $length);
    }
874007
public function read($size = 8192)
    {
        $buf = @fread($this->sock, $size);
        if ($buf === '' || $buf === false) {
            $buf = $this->ioEmptyError() ? false : null;
        }
        $this->ioFlagReset();
        return $buf;
    }
297448
public function createBinaryColumn(string $name, int $size): BinaryColumn {
		$binaryColumn = new CommonBinaryColumn($name, $size);
		$this->table->addColumn($binaryColumn);
		return $binaryColumn;
	}
1131124
public function page($page, $size) {
        if ( $page <= 0 ) $page = 1;
        $offset = ($page-1) * $size;
        return $this->offset($offset, $size);
    }
1361987
protected function parseSize($size)
    {
        $result = null;
        $size = (string) $size;
        $matches = null;
        if (preg_match('/^\s*(\d+(?:\.\d*)?)\s*(?:([bkmgtpezy])b?)?\s*/i', $size, $matches)) {
            $value = (float) $matches[1];
            $unit = empty($matches[2]) ? 'b' : strtolower($matches[2]);
            if ($unit === 'b') {
                $result = (int) $value;
            } else {
                $result = (int) round($value * pow(1024, strpos('bkmgtpezy', $unit)));
            }
        }

        return $result;
    }
1345654
public static function convertToBytes(string $size = null) : float
    {
        // Prepare the size
        $size = trim((string) $size);

        // Construct an OR list of byte units for the regex
        $accepted = implode('|', array_keys(Number::$byte_units));

        // Construct the regex pattern for verifying the size format
        $pattern = '/^([0-9]+(?:\.[0-9]+)?)('.$accepted.')?$/Di';

        // Verify the size format and store the matching parts
        if (!preg_match($pattern, $size, $matches)) {
            throw new \RuntimeException('The byte unit size, "'.$size.'", is improperly formatted.');
        }

        // Find the float value of the size
        $size = (float) $matches[1];

        // Find the actual unit, assume B if no unit specified
        $unit = Arr::get($matches, 2, 'B');

        // Convert the size into bytes
        $bytes = $size * pow(2, Number::$byte_units[$unit]);

        return $bytes;
    }