Edit report at http://bugs.php.net/bug.php?id=51496&edit=1

 ID:               51496
 Updated by:       ahar...@php.net
 Reported by:      kulakov74 at yandex dot ru
 Summary:          fgetcsv should take empty string as an escape
-Status:           Open
+Status:           Assigned
 Type:             Feature/Change Request
 Package:          Filesystem function related
 Operating System: All
 PHP Version:      5.3.2
-Assigned To:      
+Assigned To:      aharvey

 New Comment:

Sounds reasonable to me. It probably wouldn't hurt to allow the
enclosure to accept an empty string as well.



I'll cook something up for trunk and we can decide whether we want this
in 5.3 from there.


Previous Comments:
------------------------------------------------------------------------
[2010-04-07 14:34:12] kulakov74 at yandex dot ru

Description:
------------
Currently fgetcsv() gives a warning if the escape parameter is set as an
empty string (and the default is a backslash). I have some data that has
backslashes in it and it's not an escape character. Even though most of
the times fgetcsv() reads the data correctly, there is a little chance
it will do it wrong if a backslash is the last character of a multiline
cell, which is usually stored like this:



"\\\line1

line2\\\"



In order to fix that I supply chr(8) as an escape character because I
know for sure the data does not have the character. And if I pass an
empty string instead fgetcsv() will give a warning and refuse to read a
line. 



I suggest that fgetcsv() does accept an empty string as an escape and do
no escaping in that case, which is quite usual. 

For ex., a MySql statement "Load Data Infile ... Into Table" has it as
"Escaped By None" to achieve the same result. 







Test script:
---------------
if (!$Handle=fopen("sites.txt", "rb")) return false;

print_r(fgetcsv($Handle, 0, "\t", '"', ""));

fclose($Handle);



Expected result:
----------------
array( ... ) - depends on the input file

Actual result:
--------------
Warning: fgetcsv(): escape must be character in ...


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51496&edit=1

Reply via email to