Read one string from buffer ending with null byte

@return string
15872
public function GetString( )
		{
			$ZeroBytePosition = StrPos( $this->Buffer, "\0", $this->Position );
			
			if( $ZeroBytePosition === false )
			{
				return '';
			}
			
			$String = $this->Get( $ZeroBytePosition - $this->Position );
			
			$this->Position++;
			
			return $String;
		}
701735
public function getNextChar()
	{
		$character	= NULL;
		if( $this->direction == "<" )
			$this->pointer++;
		if( $this->pointer < $this->count() &&  $this->pointer >=0 )
		{
			$this->direction = ">";
			$character = $this->buffer[$this->pointer];
			$this->pointer++;
		}
		return $character;
	}
530065
public String readString () {
		if (!readVarIntFlag()) return readAsciiString(); // ASCII.
		// Null, empty, or UTF8.
		int charCount = readVarIntFlag(true);
		switch (charCount) {
		case 0:
			return null;
		case 1:
			return "";
		}
		charCount--;
		readUtf8Chars(charCount);
		return new String(chars, 0, charCount);
	}
1194011
function read($inByte = null)
    {
        $this->_assertReadable();

        $inByte = ($inByte === null)
            ?
            (
                ($this->getBuffer() === null) ? -1 : $this->getBuffer()
            )
            : $inByte;

        $stream = $this->resource()->getRHandler();
        $data   = stream_get_contents($stream, $inByte);
        if (false === $data)
            throw new \RuntimeException('Cannot read stream.');

        if (function_exists('mb_strlen'))
            $transCount = mb_strlen($data, '8bit');
        else
            $transCount = strlen($data);

        $this->_resetTransCount($transCount);

        return $data;
    }
1193995
public function read($length = null)
    {
        $buffer = '';
        $total = count($this->_streams) - 1;
        $remaining = (integer) ($length === null ? $this->_bufferSize : $length);
        $progressToNext = false;

        while ($remaining > 0) {

            // Progress to the next stream if needed.
            if ($progressToNext || $this->_streams[$this->_current]->eof()) {
                $progressToNext = false;
                if ($this->_current === $total) {
                    break;
                }
                $this->_current++;
            }

            $result = $this->_streams[$this->_current]->read($remaining);

            if (!$result) {
                $progressToNext = true;
                continue;
            }

            $buffer .= $result;
            $remaining = $length - strlen($buffer);
        }

        $this->_offset += strlen($buffer);
        return $buffer;
    }
199364
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

        $ch = -1;

        if ($this->queuedData !== null && $this->queuedData === '') {
            $this->queuedData = null;
        }

        if ($this->queuedData !== null) {
            $ch = $this->queuedData[0];
            $this->queuedData = substr($this->queuedData, 1);
            if ($this->queuedData === '') {
                $this->queuedData = null;
            }
        } else {
            $this->queuedData = $this->readLine();
            if ($this->queuedData === null) {
                $ch = -1;
            } else {
                if ($this->suffix !== null) {
                    $lf = '';
                    if (StringHelper::endsWith($this->queuedData, "\r\n")) {
                        $lf = "\r\n";
                    } elseif (StringHelper::endsWith($this->queuedData, "\n")) {
                        $lf = "\n";
                    }
                    $this->queuedData = substr($this->queuedData, 0, strlen($this->queuedData) - strlen($lf)) . $this->suffix . $lf;
                }
                return $this->read();
            }
        }
        return $ch;
    }
994928
@Override
    public String readString() {
        final char[] text0 = this.text;
        int currpos = this.position;
        char expected = text0[++currpos];
        if (expected <= ' ') {
            for (;;) {
                expected = text0[++currpos];
                if (expected > ' ') break;
            }
        }
        if (expected != '"' && expected != '\'') {
            if (expected == 'n' && text0.length > currpos + 3 && (text0[1 + currpos] == 'u' && text0[2 + currpos] == 'l' && text0[3 + currpos] == 'l')) {
                if (text0[++currpos] == 'u' && text0[++currpos] == 'l' && text0[++currpos] == 'l') {
                    this.position = currpos;
                    if (text0.length > currpos + 4) {
                        char ch = text0[currpos + 1];
                        if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') return null;
                        final int start = currpos - 3;
                        for (;;) {
                            if (currpos >= text0.length) break;
                            ch = text0[currpos];
                            if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break;
                            currpos++;
                        }
                        if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
                        this.position = currpos - 1;
                        return new String(text0, start, currpos - start);
                    } else {
                        return null;
                    }
                }
            } else {
                final int start = currpos;
                for (;;) {
                    if (currpos >= text0.length) break;
                    char ch = text0[currpos];
                    if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break;
                    currpos++;
                }
                if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
                this.position = currpos - 1;
                return new String(text0, start, currpos - start);
            }
            this.position = currpos;
            throw new ConvertException("expected a ':' after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
        }
        final int start = ++currpos;
        for (;;) {
            char ch = text0[currpos];
            if (ch == expected) {
                break;
            } else if (ch == '\\') {
                this.position = currpos - 1;
                return readEscapeValue(expected, start);
            }
            currpos++;
        }
        this.position = currpos;
        return new String(text0, start, currpos - start);
    }
1344168
public function readBinary()
    {
        $length = $this->readVInt();
        $returnValue = substr($this->_data, $this->_position, $length);
        $this->_position += $length;
        return $returnValue;
    }
211006
public function readCodedBinary()
    {
        $c = ord($this->read(self::UNSIGNED_CHAR_LENGTH));
        if ($c === self::NULL_COLUMN) {
            return '';
        }
        if ($c < self::UNSIGNED_CHAR_COLUMN) {
            return $c;
        }
        if ($c === self::UNSIGNED_SHORT_COLUMN) {
            return $this->readUInt16();
        }
        if ($c === self::UNSIGNED_INT24_COLUMN) {
            return $this->readUInt24();
        }
        if ($c === self::UNSIGNED_INT64_COLUMN) {
            return $this->readUInt64();
        }

        throw new BinaryDataReaderException('Column num ' . $c . ' not handled');
    }
363715
public function readString()
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        $string = '';
        while (($char = @fread($this->fp, 1)) !== "\x00") {
            $string .= $char;
        }

        return $string;
    }
343244
public function parseEncodedBinary()
    {
        $f = ord($this->read(1));
        if ($f <= 250) {
            return $f;
        }
        if ($f === 251) {
            return null;
        }
        if ($f === 255) {
            return false;
        }
        if ($f === 252) {
            return Binary::bytes2int($this->read(2), true);
        }
        if ($f === 253) {
            return Binary::bytes2int($this->read(3), true);
        }
        return Binary::bytes2int($this->read(8), true);
    }
986327
protected function readLine()
    {
        $buffer = '';

        while ($buffer === '') {
            if (($buffer = fgets($this->getFileHandler())) === false) {
                $this->currentLine = null;

                return;
            }
            $buffer = trim($buffer, "\n\r\0");

            if (!$this->skipEmptyLines) {
                break;
            }
        }

        $this->currentLine = $buffer;
    }
824992
public function readChar()
    {
        if ($this->buffer === null) {
            // Buffer is empty, fill it ...
            $read = $this->in->read($this->bufferSize);
            if ($read === -1) {
                $ch = -1;
            } else {
                $this->buffer = $read;

                return $this->readChar(); // recurse
            }
        } else {
            // Get next buffered char ...
            // handle case where buffer is read-in, but is empty.  The next readChar() will return -1 EOF,
            // so we just return empty string (char) at this point.  (Probably could also return -1 ...?)
            $ch = ($this->buffer !== "") ? $this->buffer{$this->bufferPos} : '';
            $this->bufferPos++;
            if ($this->bufferPos >= strlen($this->buffer)) {
                $this->buffer = null;
                $this->bufferPos = 0;
            }
        }

        return $ch;
    }
203798
public function readByte()
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        return ord(@fread($this->fp, 1));
    }
629247
protected function read()
    {
        // Ignore first byte
        fread($this->socket, 1);

        // There is also masking bit, as MSB, bit it's 0
        $payloadLength = ord(fread($this->socket, 1));

        switch ($payloadLength) {
            case 126:
                $payloadLength = unpack('n', fread($this->socket, 2));
                $payloadLength = $payloadLength[1];
                break;
            case 127:
                //$this->stdout('error', "Next 8 bytes are 64bit uint payload length, not yet implemented, since PHP can't handle 64bit longs!");
                break;
        }

        return fread($this->socket, $payloadLength);
    }
742763
public function readLine($maxLength = null)
    {
        $buffer = '';
        $size = 0;
        while (!$this->isConsumed()) {
            $byte = $this->read(1);
            $buffer .= $byte;
            // Break when a new line is found or the max length - 1 is reached
            if ($byte == PHP_EOL || ++$size == $maxLength - 1) {
                break;
            }
        }

        return $buffer;
    }
994905
private final String bufferToString(byte[] str) {
		String string = null;
		if (str != null) {
			string = AMF.CHARSET.decode(ByteBuffer.wrap(str)).toString();
			log.debug("String: {}", string);
		} else {
			log.warn("ByteBuffer was null attempting to read String");
		}
		return string;
	}