ID:          42357
 Updated by:  [EMAIL PROTECTED]
 Reported By: php at phihag dot de
-Status:      Open
+Status:      Feedback
 Bug Type:    Feature/Change Request
 PHP Version: 5.2.4RC2
 New Comment:

Does it work if you open the file in text mode ("wt") ? That *should*
do the trick.


Previous Comments:
------------------------------------------------------------------------

[2007-08-21 06:13:14] php at phihag dot de

Description:
------------
Currently, there is no way to set a custom line ending when writing CSV
files with fputcsv. For instance, this is needed when writing CSV for
various Microsoft products which require "\r\n" as line ending.
Therefore, an optional parameter $ending (as for stream_get_line),
which defaults to auto-detection (current behaviour), would be nice.

To ensure the result is still a valid CSV file, either document using
anything else than line endings (or tabs etc.) is not a good idea, or
define/use constants for the common line endings.

Reproduce code:
---------------
<?php
$f = fopen("php://stdout", "w");
fputcsv($f, array("a", "b c"), ",", '"',  "\r\n");
fclose($f);
?>

Expected result:
----------------
As a php string:
"a,\"b c\"\r\n"

Actual result:
--------------
n/a, without the last parameter: "a,\"b c\"\n" (hardcoded line ending
in file.c)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42357&edit=1

Reply via email to