|
John Mertic |
at Oct 22, 2008 at 6:33 pm
|
⇧ |
| |
Hi Stefan,
The context on how this function is being used is the case where you
are writing out to a file, so in this case I think we should be using
the EOL standards of the underlying platform. If we were just keeping
the output as a string, I could see us sticking with the standard
newline character.
And also, the function previously took a character and still will take
a character ( PHP_EOL is #defined to whatever character string should
be used for the EOL character, be it "\r\n" or "\n" ), unless I'm
missing something ( which could be since I haven't done much C in a
while ).
John Mertic
[email protected]http://jmertic.wordpress.com"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain
On Wed, Oct 22, 2008 at 10:14 AM, Stefan Walk wrote:John Mertic wrote:
Hi All,
My first patch so be gentle :-).
Per the documentation for the fputcsv() function, it adds a newline to
the end of the csv string it returns. However, it is hardcoded to be
'\n' ( default for unix newline ), while Windows uses \r\n. PHP should
do this as well.
Below is a patch to fix this issue; it uses the constant PHP_EOL to get
the correct newline to use on the current platform:
Index: php-src/ext/standard/file.c
===================================================================
RCS file: /repository/php-src/ext/standard/file.c,v
retrieving revision 1.530
diff -r1.530 file.c
2107c2107
< smart_str_appendc(&csvline, '\n');
---
smart_str_appendc(&csvline, PHP_EOL);
This can't work. Either the function takes a character or a pointer to a
character, it can't take both.
Also, a "newline" is \n. Everywhere. The "End of line"-marker is distinct
from that.
Regards,
Stefan