public function testChangeEncodingCanConvertBetweenUTF8AndUTF16()
 {
     $utf8file = new LocalFile(static::$dir . 'utf8_file.test');
     $utf8file->setEncoding('UTF-8');
     $utf8file->put(mb_convert_encoding('Some random Text €±§', 'UTF-8'));
     $isUtf8 = exec("file {$utf8file->getPath()} | grep -i " . escapeshellarg('\\butf-8\\b') . " | wc -l");
     static::assertEquals(1, $isUtf8, "Original file to convert is not utf-8");
     $newFile = $this->converter->toEncoding($utf8file, 'UTF-16');
     $isUTF16 = exec("file {$newFile->getPath()} | grep -i " . escapeshellarg('\\UTF-16\\b') . " | wc -l");
     static::assertEquals(1, $isUTF16, "Converted file should be UTF16");
 }
Beispiel #2
0
 public function testSetEncodingReturnsIsFluent()
 {
     $file = new LocalFile(static::$dir . 'file_set_encoding2.test');
     $file->put('uncompressed contents');
     $newFile = $file->setEncoding('us-ascii');
     static::assertNotNull($newFile);
     static::assertSame($file, $newFile);
 }