#26915 [Fbk->Csd]: fgetcsv and quoted enclosures
| From: | juergen at henge-ernst dot de | Date: | Thu, 15 Jan 2004 10:35:18 +0000 |
| Subject: | #26915 [Fbk->Csd]: fgetcsv and quoted enclosures | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53370@lists.php.net to get a copy of this message | ||
ID: 26915
User updated by: juergen at henge-ernst dot de
Reported By: juergen at henge-ernst dot de
-Status: Feedback
+Status: Closed
Bug Type: Filesystem function related
PHP Version: 4.3.4
New Comment:
ok seems to be fixed in php4-STABLE-200401150830
PHP 4.3.5RC2-dev (cli)
Previous Comments:
------------------------------------------------------------------------
[2004-01-15 05:27:37] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2004-01-15 05:21:55] juergen at henge-ernst dot de
Description:
------------
The following line in a csv-file does not get parsed correctly:
"one\""one","two\\two","three""three","four\""four"
For me the csv format is defined as:
If a delimiter is used inside a string/entry, the entry must be
enclosured with a character. If the encloure-character is used inside
the entry, the enclosure character must be doubled.
maybe the fix of Bug #22382 "fgetcsv does not allow escaped quotes"
introduced this behaviour.
With version 4.2.2, 4.2.3 the correct string is returned.
Reproduce code:
---------------
$str =
'"one\""one","two\\\\two","three""three","four\""four"';
$x=fopen("x.csv","w");
fputs($x, $str);
fclose($x);
$x=fopen("x.csv","r");
while ($y=fgetcsv($x,1000,","))
var_dump($y);
Expected result:
----------------
array(4) {
[0]=>
string(5) "one\"one"
[1]=>
string(8) "two\\two"
[2]=>
string(11) "three"three"
[3]=>
string(6) "four\"four"
}
Actual result:
--------------
array(4) {
[0]=>
string(5) "one\""
[1]=>
string(8) "two\\two"
[2]=>
string(11) "three"three"
[3]=>
string(6) "four\""
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26915&edit=1