Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12549 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66753 invoked by uid 1010); 2 Sep 2004 18:17:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 51448 invoked from network); 2 Sep 2004 17:54:20 -0000 Received: from unknown (HELO jan.prima.de) (83.97.50.139) by pb1.pair.com with SMTP; 2 Sep 2004 17:54:20 -0000 Received: from BAUMBART (p508EB5AE.dip.t-dialin.net [::ffff:80.142.181.174]) (IDENT: HydraIRC, AUTH: LOGIN tobi) by jan.prima.de with esmtp; Thu, 02 Sep 2004 17:54:15 +0000 Date: Thu, 2 Sep 2004 19:52:11 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <93595154.20040902195211@marcus-boerger.de> To: David Sklar CC: internals@lists.php.net In-Reply-To: <413747AF.4020301@sklar.com> References: <411A24C7.9090507@sklar.com> <5176941.20040811204007@marcus-boerger.de> <1853829533.20040901231956@marcus-boerger.de> <413747AF.4020301@sklar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] fputcsv() From: helly@php.net (Marcus Boerger) Hello David, i looked up the fputcsv() magic in the file manually and agree that this is fairly correct (as i wrote before). But when i execute the test the second var_export() is supposed to show the input from the .phpt file. Unfortunatley i get a FAIL from run-tests.php: FAIL various fputcsv() functionality tests [ext/standard/tests/file/fputcsv.phpt] 040+ 16 => 'aaa,"\\"bbb",ccc', 041+ 17 => 'aaa"\\"a""","bbb"', 042+ 18 => '"\\""","aaa"""', 043+ 19 => '"\\"""",aaa 044+ ', 040- 16 => 'aaa,"\\"bbb,ccc', 041- 17 => 'aaa"\\"a","bbb"', 042- 18 => '"\\"","aaa"', 043- 19 => '"\\""",aaa',marcus@frodo /usr/src/php-cvs $ Care to look into this (done with current HEAD)? best regards marcus Thursday, September 2, 2004, 6:17:51 PM, you wrote: > 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 -- Best regards, Marcus mailto:helly@php.net