|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-25 04:18 UTC] iliaa@php.net
[2005-07-29 01:05 UTC] vasilyev at math dot uchicago dot edu
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Description: ------------ This has been already mentioned in several bugs, that were all dismissed as bogus. Nevertheless, I believe there is a serious problem with the way fgetcsv treats backslash. Example: "a\","b" produces Array ( [0] => a\",b" ) iliia@php.net says that this is an expected behavior since backslash is an escaping character. Well, if this were true then "a\"b","c" would give Array ( [0] => a"b [1] => c ) while in fact you get Array ( [0] => a\"b [1] => c ) Another scenario: what do you do if you want to have a backslash at the end of a field (and let's say there are commas in that field, so we do have to use quotes). Well the natural answer is to escape the backslash: "a\\","b" but this would produce Array ( [0] => a\\ [1] => b ) It seems that the only thing a backslash does is making fgetcsv() not treat the following quote as an enclosure mark, without actually stripping the backslash. This is not escaping. There are two ways this can be fixed: 1.Make backslash an escaping character. This would further deviate fgetcsv() parsing of CSV files from the wide-spread understanding of what a CSV format is. 2.Treat backslash as any other character. I would prefer the second choice.