Bug #74713 [Opn]: CSV cell split after fputcsv() + fgetcsv() round trip.

From: Date: Thu, 21 Sep 2017 16:48:41 +0000
Subject: Bug #74713 [Opn]: CSV cell split after fputcsv() + fgetcsv() round trip.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211316@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74713&edit=1 ID: 74713 Updated by: cmb@php.net Reported by: andreas at dqxtech dot net Summary: CSV cell split after fputcsv() + fgetcsv() round trip. Status: Open Type: Bug Package: Filesystem function related Operating System: Linux / 3v4l PHP Version: 7.1.5 Block user comment: N Private report: N New Comment: > So how could we achieve this? Do we need an RFC for this? I've already sent a respective mail to the internals list[1]. If there'll be no massive objections, I'm planning to pursue the RFC process. [1] <http://news.php.net/php.internals/100729> Previous Comments: ------------------------------------------------------------------------ [2017-09-21 16:09:45] andreas at dqxtech dot net > It would be better, though, if one could pass an empty > string or maybe NULL, and perhaps to make that the default in PHP 8. Yes. So how could we achieve this? Do we need an RFC for this? ------------------------------------------------------------------------ [2017-09-21 11:27:31] cmb@php.net > Sorry, but "use a user land parser because someone may rely on buggy behavior > hence we keep" is a bad attitude Well, this is not really a bug, but rather related to the escape character, which is a non-standard extension. Removing the escape character may very well cause a BC break for applications relying on it. Anyhow, currently, a quite acceptable workaround is to pass "\0" as $escape argument to fputcsv(). It would be better, though, if one could pass an empty string or maybe NULL, and perhaps to make that the default in PHP 8. ------------------------------------------------------------------------ [2017-06-12 07:06:32] spam2 at rhsoft dot net Sorry, but "use a user land parser because someone may rely on buggy behavior hence we keep" is a bad attitude ------------------------------------------------------------------------ [2017-06-12 02:50:56] andreas at dqxtech dot net > I'd recommend using a userland CSV parser instead. Maybe you can write the same thing on the stackoverflow question :) https://stackoverflow.com/questions/44427926/data-gets-garbled-when-writing-to-csv-with-fputcsv-fgetcsv ------------------------------------------------------------------------ [2017-06-12 02:49:17] andreas at dqxtech dot net > fputcsv() does not seem to support this. I should clarify: fputcsv() does duplicate most of the quotes. But it always treats the $escape_char in a special way, so we can end up with non-duplicate quotes around escape characters. There does not seem to be a mode in fputcsv() that does not have an $escape_char. (Btw the documentation for $escape_char should be improved, I don#t really understand what this parameter intends to do) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=74713 -- Edit this bug report at https://bugs.php.net/bug.php?id=74713&edit=1

« previous php.bugs (#211316) next »