Regarding the latest patch on fgetcsv() (stable branch)
| From: | Moriyoshi Koizumi | Date: | Fri, 12 Dec 2003 18:36:49 +0000 |
| Subject: | Regarding the latest patch on fgetcsv() (stable branch) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-6362@lists.php.net to get a copy of this message | ||
Hi Ilia,
During the verification of bug #26600, I just noticed
fgetcsv() now behaves differently than the previous release 4.3.4.
After a quick examination, I found the change you made
on r-1.279.2.41 is related to this issue.
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.41&r2=1.279.2.42&ty=h
Before the patch, the test case attached below had given the
following result:
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
Since it was patched, fgetcsv() returns the following:
array(3) {
[0]=>
string(1) "a"
[1]=>
string(2) " b"
[2]=>
string(2) " c"
}
While I think the new behaviour is consistent with the CSV format
used by Microsoft Excel, it'd be a BC problem also.
Test case:
<?php
$file = '/tmp/test.csv';
$fp = fopen($file, 'w');
fwrite($fp, "a, b, c\n");
fclose($fp);
$fp = fopen($file, 'r');
var_dump(fgetcsv($fp, filesize($file)));
fclose($fp);
?>
What do you think of this?
Moriyoshi