Re: [PATCH] Bug #46367 - fputcsv does not add the correct newline character on Windows
| From: | John Mertic | Date: | Tue, 07 Jul 2009 21:10:03 +0000 |
| Subject: | Re: [PATCH] Bug #46367 - fputcsv does not add the correct newline character on Windows | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44793@lists.php.net to get a copy of this message | ||
The big issue I saw was that fgetcsv() used PHP_EOL for determining
line endings, but fputcsv() didn't, which on Windows was causing csv
files written by PHP not be able to be read back ( assuming
auto_detect_line_endings is turned off ).
John Mertic
jmertic@gmail.com | http://jmertic.wordpress.com
On Tue, Jul 7, 2009 at 3:22 PM, Brian Moon<brianlmoon@php.net> wrote:
> On 7/7/09 1:27 PM, Jani Taskinen wrote:
>>
>> John Mertic kirjoitti:
>>>
>>> Hi All,
>>>
>>> Bringing this one back once more; let me know what everyone thinks
>>> about it. If it's safe to commit than if someone could ( or give me
>>> the karma to do so ) that would be great. If not, let me know what
>>> should be done about it instead.
>>
>> Is \r\n okay on Mac? Is \r okay on Windows? etc.
>>
>> Short: Shouldn't this be always \r\n? Or better yet, default to \r\n and
>> add extra option for fputcsv with which you can set it to anything you
>> like.. :)
>>
>> --Jani
>
> The only program I know of in existence that has issues is Notepad on
> Windows. All the mac programs I use will deal with whatever.
>
> Having said that, it should be just as flexible for creating CSV files as
> fgetcsv is for reading them.
>
> Of course, a good ol' fputs does a fine job of making a CSV file too.
>
> --
>
> Brian.
> --------
> http://brian.moonspot.net/
>