Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78997 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40705 invoked from network); 19 Nov 2014 14:39:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2014 14:39:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wg0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:45342] helo=mail-wg0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/44-15892-49BAC645 for ; Wed, 19 Nov 2014 09:39:16 -0500 Received: by mail-wg0-f41.google.com with SMTP id y19so1022636wgg.28 for ; Wed, 19 Nov 2014 06:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=h7FbFYndgW0/X9gqimzrJTovXNpshy1zMH/8AC5wa5s=; b=wp7eFVvx587/q1RKvb3Znx+JypJtyRdYP0qjqZHz9fOSLpEZZoUlJ37B1hzoh6wmTw Dxk7npzMWMqjJXzrgxpxpnrsZa2Rgq4zpbAwb9GkmqeHBRG/GyFOH8NQBYGrHxqJCrR8 1o8Yp9hYuelqVC6MIGPuuIqiB6T/ODTQiMOlrB2A/md9ePzXvOLhND9+dqy0kjlyqhBD sVcQX/eKeyGp2ZMDN/f7ocRpDASuGMlKGoYf80mVg09KF2OpfEpwCQPFQkdSlgQ4y1Ap Wdf0taaw4NsHZth3grQh0d/Jdj4NzWSJigvrcjZnYVmbRYXAMhAa8t5L8eTMfwQiNg+9 AUNg== X-Received: by 10.194.191.227 with SMTP id hb3mr54538787wjc.79.1416407953380; Wed, 19 Nov 2014 06:39:13 -0800 (PST) Received: from [192.168.0.148] ([62.189.198.114]) by mx.google.com with ESMTPSA id p7sm2530677wjo.38.2014.11.19.06.39.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2014 06:39:12 -0800 (PST) Message-ID: <546CAB88.4040809@gmail.com> Date: Wed, 19 Nov 2014 14:39:04 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <82139FDD-8D8B-43D9-B811-ECC1FFE6E8A6@gmail.com> In-Reply-To: <82139FDD-8D8B-43D9-B811-ECC1FFE6E8A6@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: fgetcsv incompatible with fputcsv From: rowan.collins@gmail.com (Rowan Collins) Tjerk Meesters wrote on 19/11/2014 12:20: > Hi list, > > As I was fiddling with CSV data reading and writing I noticed that fgetcsv() is inherently incompatible with fputcsv() when it comes to the enclosure escape character that’s used. > > Example: http://3v4l.org/LHEZj > > The above example code demonstrates how, by default, fputcsv() encodes a backslash as is but fgetcsv() will treat that same backslash as the enclosure escape character as well as the enclosure character itself; this is rather surprising behaviour and imho unnecessarily complicated. > > I would suggest changing the behaviour in such a way that: > a) the default enclosure escape character for fgetcsv() is a double quote. > b) fgetcsv() only treats the escape character as … an escape character. > > Due to the kind of change BC can’t be maintained, so I’d propose this change for PHP 7. > > If anyone has violent objections to the above, or thinks that an RFC should be drawn up, do let me know … otherwise I’ll commit the change into master by next week or so. > > > Best, > Tjerk If I remember rightly, some of the escaping behaviour is actually incompatible with MS Excel (I believe 2000 was the current version when I tested) as well, which struck me as rather unfortunate. However, I'm always a bit wary of subtle breaking changes like this, so we need to be sure we definitely get it right this time, and that there are documented options to both functions which emulate the old behaviour. Regards, -- Rowan Collins [IMSoP]