[PHP-DEV] fputcsv is not compliant with the CSV RFC

2020-11-14 Thread Cameron Hall
Hi internals, I've come across a small nuance recently noticing that the fputcsv function isn't compliant with the RFC because it uses LF as a line terminator instead of CRLF as per RFC 4810[1]. There are a few related bug reports already; #42357[4], #46367[2] and #62770[3]. I've created a pull r

Re: [PHP-DEV] fputcsv() and $escape character

2018-09-13 Thread Rowan Collins
On 13/09/2018 16:55, Theodore Brown wrote: If the patch was also applied to PHP 7.2 and 7.1, we wouldn't need to add fallback code in the League/Csv library for these versions. I understand if this isn't possible, but I'm trying to figure out how best to approach fixing the issue in League/Csv.

Re: [PHP-DEV] fputcsv() and $escape character

2018-09-13 Thread Christoph M. Becker
On 13.09.2018 at 17:55, Theodore Brown wrote: > On Thursday, September 13, 2018 at 7:30 AM Christoph M. Becker > wrote: > >> I've submitted . > > Thanks so much for your work on this! Do you know if the patch can be > included in PHP 7.3? > > If the p

Re: [PHP-DEV] fputcsv() and $escape character

2018-09-13 Thread Theodore Brown
On Thursday, September 13, 2018 at 7:30 AM Christoph M. Becker wrote: >> Ironically, the League/Csv library uses `fputcsv()` behind the scenes, >> and thus suffers from the same escape character problem >> (see https://github.com/thephpleague/csv/issues/307). >> >> Is there any chance `fputcsv()

Re: [PHP-DEV] fputcsv() and $escape character

2018-09-13 Thread Christoph M. Becker
On 09.09.2018 at 16:55, Theodore Brown wrote: > On Friday, Sep. 22, 2017 at 5:09 PM Christoph M. Becker > wrote: > There are several bug reports regarding "broken" `fputcsv()` behavior in our tracker, namely, because the $escape parameter causes unexpected results. For instance:

Re: [PHP-DEV] fputcsv() and $escape character

2018-09-09 Thread Theodore Brown
On Friday, Sep. 22, 2017 at 5:09 PM Christoph M. Becker wrote: >>> There are several bug reports regarding "broken" `fputcsv()` behavior >>> in our tracker, namely, because the $escape parameter causes unexpected >>> results. For instance: >> >> I looked at fixing some of the CSV related bugs ab

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-22 Thread Christoph M. Becker
On 21.09.2017 at 23:08, Dan Ackroyd wrote: > On 21 September 2017 at 12:43, Christoph M. Becker wrote: > >> There are several bug reports regarding "broken" fputcsv() behavior in >> our tracker, namely, because the $escape parameter causes unexpected >> results. For instance: > > I looked at fi

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-22 Thread Andreas Hennings
On Fri, Sep 22, 2017 at 1:20 PM, Christoph M. Becker wrote: >> please make sure the behaviour of common applications, most notably >> Excel, is considered and tested. In my experience it has its own quirks, >> and it's likely that a large proportion of users require >> interoperability with it. It

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-22 Thread Christoph M. Becker
On 21.09.2017 at 20:01, Rowan Collins wrote: > On 21 September 2017 18:32:57 BST, Andreas Hennings > wrote: > >> So empty string would enable the standard behavior RFC 7111 with no >> escape char. >> If so, I support this. > > Just a note regarding standards: Actually, there is no accepted st

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-21 Thread Andreas Hennings
On Thu, Sep 21, 2017 at 1:43 PM, Christoph M. Becker wrote: > I don't think the current behavior is a bug, but rather the escape > character is an extension to the CSV "standard" (RFC 7111). Are you sure you mean RFC 7111 ? I was just parrotting the number in my previous email, but now I looked i

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-21 Thread Andreas Hennings
On Thu, Sep 21, 2017 at 11:08 PM, Dan Ackroyd wrote: > On 21 September 2017 at 12:43, Christoph M. Becker wrote: >> Hi everybody! >> >> There are several bug reports regarding "broken" fputcsv() behavior in >> our tracker, namely, because the $escape parameter causes unexpected >> results. For i

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-21 Thread Dan Ackroyd
On 21 September 2017 at 12:43, Christoph M. Becker wrote: > Hi everybody! > > There are several bug reports regarding "broken" fputcsv() behavior in > our tracker, namely, because the $escape parameter causes unexpected > results. For instance: I looked at fixing some of the CSV related bugs ab

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-21 Thread Rowan Collins
On 21 September 2017 18:32:57 BST, Andreas Hennings wrote: >So empty string would enable the standard behavior RFC 7111 with no >escape char. >If so, I support this. Just a note regarding standards: please make sure the behaviour of common applications, most notably Excel, is considered and test

Re: [PHP-DEV] fputcsv() and $escape character

2017-09-21 Thread Andreas Hennings
So empty string would enable the standard behavior RFC 7111 with no escape char. If so, I support this. I don't know if '' or true / false / null should be this "special value". It has to be something that was not legal before, and that people should use intentionally and not by accident. I guess

[PHP-DEV] fputcsv() and $escape character

2017-09-21 Thread Christoph M. Becker
Hi everybody! There are several bug reports regarding "broken" fputcsv() behavior in our tracker, namely, because the $escape parameter causes unexpected results. For instance: outputs "a\"",bbb instead of the expected "a\""",bbb I don't think the current behavior is a bug, but

Re: [PHP-DEV] fputcsv()

2004-09-03 Thread Marcus Boerger
Hello David, it is obviously fgetcsv(), see last comment on #29719 [Opn]: fgetcsv - double quotes issue marcus Thursday, September 2, 2004, 10:26:18 PM, you wrote: > Marcus Boerger wrote: >> Hello David, >> >> i looked up the fputcsv() magic in the file manually and agree that this >> is

Re: [PHP-DEV] fputcsv()

2004-09-02 Thread Curt Zirzow
* Thus wrote Marcus Boerger: > 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 opin

Re: [PHP-DEV] fputcsv()

2004-09-02 Thread David Sklar
Marcus Boerger wrote: 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: F

Re: [PHP-DEV] fputcsv()

2004-09-02 Thread 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(

Re: [PHP-DEV] fputcsv()

2004-09-02 Thread 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(

Re: [PHP-DEV] fputcsv()

2004-09-01 Thread Marcus Boerger
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.

Re: [PHP-DEV] fputcsv()

2004-08-11 Thread Marcus Boerger
Hello David, Wednesday, August 11, 2004, 3:53:11 PM, you wrote: > Attached is my fputcsv() patch (and a test case) from April. Could > someone commit this to 5.1 or 5.0.1? That's a new function so it can only go to 5.1. Anyway it's a nice feature. So if nobody has anything against i'd look into

[PHP-DEV] fputcsv()

2004-08-11 Thread David Sklar
Attached is my fputcsv() patch (and a test case) from April. Could someone commit this to 5.1 or 5.0.1? Thanks, David Index: ext/standard/file.c === RCS file: /repository/php-src/ext/standard/file.c,v retrieving revision 1.380 diff -

[PHP-DEV] fputcsv commit

2004-04-27 Thread David Sklar
Is my fputcsv patch going to be committed before or after the release of PHP 5.0.0? I don't particularly care either way (it's not a bugfix so presumably after 5.0.0?) but if it will be before 5.0.0 then I will mention it in an in-progress book; otherwise not. Thanks, David -- PHP Internals - P

Re: [PHP-DEV] fputcsv()

2004-04-12 Thread David Sklar
Thanks for the line-ending feedback everyone, and Ilia for the code cleanup. Attached is a diff that implements the (cleaned up) function and a test file for tests/basic. If someone with appropriate karma could commit these, that'd be great. Thanks, David Index: ext/standard/file.c =

Re: [PHP-DEV] fputcsv()

2004-04-12 Thread Derick Rethans
On Sun, 11 Apr 2004, David Sklar wrote: > Perfect, thanks. I knew there was a #define lurking around somewhere > that was \r\n, \r, or \n, as appropriate, I just didn't know what it was > called. I don't think it's a good idea to do this as it causes different output on different systems. This me

Re: [PHP-DEV] fputcsv()

2004-04-11 Thread Moriyoshi Koizumi
On 2004/04/12, at 1:33, David Sklar wrote: Attached is a patch that implements fputcsv() as a complement to fgetcsv(). There are two things that still need improvement: - It adds "\n" as a newline onto the end of each line. I think it would be better to add a platform-specific line ending. -

Re: [PHP-DEV] fputcsv()

2004-04-11 Thread Ilia Alshanetsky
Hi David, I've made a slight revision to your proposed patch with adds the following changes: 1) Raise notice when delimeter or enclosure are >1 character long. 2) Fixed a crash with custom delimeters & enclosures. 3) Made fields with spaces and tabs be enclosed. 4) Simplify the code & made it a

Re: [PHP-DEV] fputcsv()

2004-04-11 Thread David Sklar
Perfect, thanks. I knew there was a #define lurking around somewhere that was \r\n, \r, or \n, as appropriate, I just didn't know what it was called. David Andi Gutmans wrote: How about using PHP_EOL? At 12:33 PM 4/11/2004 -0400, David Sklar wrote: Attached is a patch that implements fputcsv

Re: [PHP-DEV] fputcsv()

2004-04-11 Thread Andi Gutmans
How about using PHP_EOL? At 12:33 PM 4/11/2004 -0400, David Sklar wrote: Attached is a patch that implements fputcsv() as a complement to fgetcsv(). There are two things that still need improvement: - It adds "\n" as a newline onto the end of each line. I think it would be better to add a platf

[PHP-DEV] fputcsv()

2004-04-11 Thread David Sklar
Attached is a patch that implements fputcsv() as a complement to fgetcsv(). There are two things that still need improvement: - It adds "\n" as a newline onto the end of each line. I think it would be better to add a platform-specific line ending. - It is not mbstring-aware. Any suggestions fo