/** * @group ZF-9450 */ public function testUnescapeOctal() { $input = array(0304 => '\\304', 0326 => '\\326', 0334 => '\\334'); foreach ($input as $k => $v) { $this->assertEquals(InternalType\StringObject::unescape($v), chr($k), 'expected German Umlaut'); } }
/** * Read string PDF object * Also reads trailing ')' from a pdf stream * * @return \Zend\Pdf\InternalType\StringObject * @throws \Zend\Pdf\Exception */ private function _readString() { $start = $this->offset; $openedBrackets = 1; $this->offset += strcspn($this->data, '()\\', $this->offset); while ($this->offset < strlen($this->data)) { switch (ord($this->data[$this->offset])) { case 0x28: // '(' - opened bracket in the string, needs balanced pair. $this->offset++; $openedBrackets++; break; case 0x29: // ')' - pair to the opened bracket $this->offset++; $openedBrackets--; break; case 0x5c: // '\\' - escape sequence, skip next char from a check $this->offset += 2; } if ($openedBrackets == 0) { break; // end of string } $this->offset += strcspn($this->data, '()\\', $this->offset); } if ($openedBrackets != 0) { throw new Pdf\Exception(sprintf('PDF file syntax error. Unexpected end of file while string reading. Offset - 0x%X. \')\' expected.', $start)); } return new InternalType\StringObject(InternalType\StringObject::unescape(substr($this->data, $start, $this->offset - $start - 1))); }