diff options
author | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2015-01-15 13:44:25 +0100 |
---|---|---|
committer | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2015-01-15 13:44:25 +0100 |
commit | 4af04d1094f931d34dc42a39d79af958efb81b6d (patch) | |
tree | e61f029b12e25f03607eda5f9bb8954620e7e69f | |
parent | 726679435b4330bcffe1fddd5c4eab268aba82af (diff) | |
download | csv-4af04d1094f931d34dc42a39d79af958efb81b6d.zip csv-4af04d1094f931d34dc42a39d79af958efb81b6d.tar.gz csv-4af04d1094f931d34dc42a39d79af958efb81b6d.tar.bz2 |
bug fix BOM feature
-rw-r--r-- | src/AbstractCsv.php | 6 | ||||
-rw-r--r-- | test/CsvTest.php | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 8f337f4..f50b049 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -320,9 +320,9 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="'.rawurlencode($filename).'"'); - if ($this->bom_on_output) { - echo chr(239).chr(187).chr(191); - } + } + if ($this->bom_on_output) { + echo chr(239).chr(187).chr(191); } //@codeCoverageIgnoreEnd $iterator->rewind(); diff --git a/test/CsvTest.php b/test/CsvTest.php index 267790d..c488afb 100644 --- a/test/CsvTest.php +++ b/test/CsvTest.php @@ -112,6 +112,14 @@ class CsvTest extends PHPUnit_Framework_TestCase $this->assertTrue($this->csv->hasBOMOnOutput()); } + public function testAddBOMSequences() + { + $this->csv->setBOMOnOutput(true); + $expected = chr(239).chr(187).chr(191)."john,doe,john.doe@example.com".PHP_EOL + ."jane,doe,jane.doe@example.com".PHP_EOL; + $this->assertSame($expected, $this->csv->__toString()); + } + /** * @expectedException InvalidArgumentException * @expectedExceptionMessage `$nb_rows` must be a valid positive integer |