write()); return $txt2; } public function expect($str) { return self::HEADER . $str . self::TRAILER; } /** * Test special characters which require escaping. */ public function testSpecial(): void { $str = 'Special characters { open brace } close brace \\ backslash'; $expect = $this->expect('Special characters \\{ open brace \\} close brace \\\\ backslash'); self::assertEquals($expect, $this->escapestring($str)); } /** * Test accented character. */ public function testAccent(): void { $str = 'Voilà - string with accented char'; $expect = $this->expect('Voil\\uc0{\\u224} - string with accented char'); self::assertEquals($expect, $this->escapestring($str)); } /** * Test Hebrew. */ public function testHebrew(): void { $str = 'Hebrew - שלום'; $expect = $this->expect('Hebrew - \\uc0{\\u1513}\\uc0{\\u1500}\\uc0{\\u1493}\\uc0{\\u1501}'); self::assertEquals($expect, $this->escapestring($str)); } /** * Test tab. */ public function testTab(): void { $str = "Here's a tab\tfollowed by more characters."; $expect = $this->expect("Here's a tab{\\tab}followed by more characters."); self::assertEquals($expect, $this->escapestring($str)); } }