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