private function getChars($n)
{
$response = null;
// do we need more data?
if ($this->strpos + $n - 1 >= strlen($this->str)) {
$end = $this->strpos + $n;
while (strlen($this->str) < $end && $response !== false) {
// read more from the file handle
$need = $end - ftell($this->handle);
if ($response = fread($this->handle, $need)) {
$this->str .= $response;
} else {
return false;
}
}
}
$result = substr($this->str, $this->strpos, $n);
$this->strpos += $n;
return $result;
}