#33179 [Bgs]: backslash is not an escape character in correct CSV
| From: | fsb at thefsb dot org | Date: | Wed, 01 Jun 2005 00:25:26 +0000 |
| Subject: | #33179 [Bgs]: backslash is not an escape character in correct CSV | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79777@lists.php.net to get a copy of this message | ||
ID: 33179
User updated by: fsb at thefsb dot org
Reported By: fsb at thefsb dot org
Status: Bogus
Bug Type: Filesystem function related
Operating System: os x 10.3 and freebsd 5.3
PHP Version: 4.3.10
New Comment:
if backslash were an escape character to PHP then it
would not appear in the parsed values from the following
csv file:
abc,123,abc,123,abc,123
abc,\ 123,abc,123,abc,123
abc,123\ ,abc,123,abc,123
abc,123,abc\,123,abc,123
abc,123,\"abc",123,abc,123
abc,123,"a\""bc",123,abc,123
abc,123,"a"\"bc",123,abc,123
abc,123,"a""bc"\ ,123,abc,123
in every case above, the backslash preceeds a special
caracter in the csv file format. if backshalsh were
generally an escape character then in these positions it
should be removed by the csv parser leaving the
following character as literal.
Previous Comments:
------------------------------------------------------------------------
[2005-05-31 01:18:39] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
As far as PHP is concerned backslash is an escape characte, which makes
the demonstrated behaviour expected.
------------------------------------------------------------------------
[2005-05-30 02:22:52] fsb at thefsb dot org
Description:
------------
why can i have a \ at the end of a field but not
if i wrap it in " field delimiters? e.g.
abc,123\,abc works fine but
"abc","123\",abc produces only two columns
this question has been asked before (#29278, #30476,
etc.) and iliaa@php.net rejects the bug as bogus. i
don't agree.
if this is not a bug then this unusual use of \ to
escape only closing field delimiting double quotes
but not escape any other instances of double qotes or
(it would appear) any other character SHOULD be
documented. it is not.
moreover this undocumented feature is not consistent
with the specification of the CSV file format found
here: http://www.creativyst.com/Doc/Articles/CSV/
CSV01.htm
this csv spec suggests that backslash has no special
meaning in the CSV format at all. indeed, in all my
tests, fgetcsv appears to accord it no special meaning
_except_ in this one particular case.
such a surprising behaviour that deviates from common
CSV file format conventions SHOULD be documented (or
corrected).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33179&edit=1