Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12546 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74895 invoked by uid 1010); 2 Sep 2004 16:36:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 95463 invoked from network); 2 Sep 2004 16:17:55 -0000 Received: from unknown (HELO home.sklar.com) (24.199.89.111) by pb1.pair.com with SMTP; 2 Sep 2004 16:17:55 -0000 Received: from [127.0.0.1] ([127.0.0.1]) by home.sklar.com with Microsoft SMTPSVC(6.0.2600.1106); Thu, 2 Sep 2004 12:17:51 -0400 Message-ID: <413747AF.4020301@sklar.com> Date: Thu, 02 Sep 2004 12:17:51 -0400 User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marcus Boerger CC: internals@lists.php.net References: <411A24C7.9090507@sklar.com> <5176941.20040811204007@marcus-boerger.de> <1853829533.20040901231956@marcus-boerger.de> In-Reply-To: <1853829533.20040901231956@marcus-boerger.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Sep 2004 16:17:51.0406 (UTC) FILETIME=[6508D4E0:01C49108] Subject: Re: [PHP-DEV] fputcsv() From: sklar@sklar.com (David Sklar) Marcus Boerger wrote: > Hello David, > > as promised i looked at the patch. Besides a small misstake it looks > good. But it seems to work different then fgetcsv(). In other words if > you write using fputcsv() you are not sure to get the same back with > fgetcsv(). Though my current opinion is that fputcsv() is doing it right. > The attached patch includes a testfile that demonstrates the problem. > > anyone having thoughts? I agree that if you write something with fputcsv() and then read it with fgetcsv() you should get back what you started with. I don't see what's broken though. (Maybe I am misunderstanding your test cases.) The original array in the test file is: > +$list = array ( > + 0 => 'aaa,bbb', > + 1 => 'aaa,"bbb"', > + 2 => '"aaa","bbb"', > + 3 => 'aaa,bbb', > + 4 => '"aaa",bbb', > + 5 => '"aaa", "bbb"', > + 6 => ',', > + 7 => 'aaa,', > + 8 => ',"aaa"', > + 9 => '"",""', > + 10 => '"""""",', > + 11 => '""""",aaa', > + 12 => 'aaa,bbb ', > + 13 => 'aaa,"bbb "', > + 14 => 'aaa"aaa","bbb"bbb', > + 15 => 'aaa"aaa""",bbb', > + 16 => 'aaa,"\\"bbb,ccc', > + 17 => 'aaa"\\"a","bbb"', > + 18 => '"\\"","aaa"', > + 19 => '"\\""",aaa', And then what gets printed out by fputcsv() is this: (which is different, but that's OK, since fputcsv() has worked its encoding magic): > +$list = array ( > + 0 => 'aaa,bbb', > + 1 => 'aaa,"""bbb"""', > + 2 => '"""aaa""","""bbb"""', > + 3 => 'aaa,bbb', > + 4 => '"""aaa""",bbb', > + 5 => '"""aaa"""," ""bbb"""', > + 6 => ',', > + 7 => 'aaa,', > + 8 => ',"""aaa"""', > + 9 => '"""""",""""""', > + 10 => '"""""""""""""",', > + 11 => '"""""""""""",aaa', > + 12 => 'aaa,"bbb "', > + 13 => 'aaa,"""bbb """', > + 14 => '"aaa""aaa""","""bbb""bbb"', > + 15 => '"aaa""aaa""""""",bbb', > + 16 => 'aaa,"""\\""bbb",ccc', > + 17 => '"aaa""\\""a""","""bbb"""', > + 18 => '"""\\""""","""aaa"""', > + 19 => '"""\\""""""",aaa', > +); And then this is the array after being read in by fgetcsv(): > +$list = array ( > + 0 => 'aaa,bbb', > + 1 => 'aaa,"bbb"', > + 2 => '"aaa","bbb"', > + 3 => 'aaa,bbb', > + 4 => '"aaa",bbb', > + 5 => '"aaa", "bbb"', > + 6 => ',', > + 7 => 'aaa,', > + 8 => ',"aaa"', > + 9 => '"",""', > + 10 => '"""""",', > + 11 => '""""",aaa', > + 12 => 'aaa,bbb ', > + 13 => 'aaa,"bbb "', > + 14 => 'aaa"aaa","bbb"bbb', > + 15 => 'aaa"aaa""",bbb', > + 16 => 'aaa,"\\"bbb,ccc', > + 17 => 'aaa"\\"a","bbb"', > + 18 => '"\\"","aaa"', > + 19 => '"\\""",aaa', > +); Which seems to be the same as the original array? David