From:             andy at invocation dot ltd dot uk
Operating system: Linux
PHP version:      4.3.9
PHP Bug Type:     Filesystem function related
Bug description:  fgetcsv treats \" incorectly

Description:
------------
The function fgetcsv assumes that a \ within a line of a CSV file is an
escape character, this is inconsistant with the csv output of most (if not
all) applications.

For example:

"foo","bar\","wombat"

Is 3 fields, but fgetcsv interprets this as 2 fields as the quote at the
end of bar is considered escaped. 

Both Open Office and Microsoft Works (hence probably also Excel) would
genrate the above line from a spreadsheet looking like:

1       2        3
foo     bar\     wombat

Gnumeric does not put quotes round each text field unless it has to (i.e.
contains a " or , in the text) but if you have:

foo     b,ar\    wombat

you get:

foo,"b,ar\",wombat

This would again, I suspect, confuse the php fgetcsv function.

I appreciate that the csv file format is not covered by any proper
standards but it would be nice if its behaviour could be made compatable
with popular spreadsheets.

This is essentialy the same report is someone else submitted (#28347).
This was rejected, unfairly in my opinion, as bogus.



Reproduce code:
---------------
See Bug #28347 for example code and results.

Expected result:
----------------
See Bug #28347 for example code and results.

Actual result:
--------------
See Bug #28347 for example code and results.

-- 
Edit bug report at http://bugs.php.net/?id=30476&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30476&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30476&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30476&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30476&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30476&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30476&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30476&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30476&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30476&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30476&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30476&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30476&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30476&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30476&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30476&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30476&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30476&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30476&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30476&r=mysqlcfg

Reply via email to