#26915 [Opn->Fbk]: fgetcsv and quoted enclosures
| From: | sniper@php.net | Date: | Thu, 15 Jan 2004 10:27:37 +0000 |
| Subject: | #26915 [Opn->Fbk]: fgetcsv and quoted enclosures | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53368@lists.php.net to get a copy of this message | ||
ID: 26915
Updated by: sniper@php.net
Reported By: juergen at henge-ernst dot de
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
PHP Version: 4.3.4
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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