Fix charachters escaping with CSV reader/writer
PHP's built-in functions fputcsv and fgetcsv are not RFC-4180 compliant and include an escape character that's not defined in the spec. This results in escaping characters that should not be escaped. This commit disables this escaping mechanism.
This commit is contained in:
1 parent
e2b519d6f9
commit
c826d15472
4 files changed
+38
-3
No files matched your search
@@ -219,12 +219,23 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('This is, a comma', $allRows[0][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testReadShouldSupportEscapedCharacters()
|
||||
{
|
||||
$allRows = $this->getAllRowsForFile('csv_with_escaped_characters.csv');
|
||||
|
||||
$expectedRow = ['"csv--11"', 'csv--12\\', 'csv--13\\\\', 'csv--14\\\\\\'];
|
||||
$this->assertEquals([$expectedRow], $allRows);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testReadShouldNotTruncateLineBreak()
|
||||
{
|
||||
$allRows = $this->getAllRowsForFile('csv_with_line_breaks.csv', ',');
|
||||
$allRows = $this->getAllRowsForFile('csv_with_line_breaks.csv');
|
||||
$this->assertEquals("This is,\na comma", $allRows[0][0]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user