From:             php at phihag dot de
Operating system: 
PHP version:      5.2.4RC2
PHP Bug Type:     Feature/Change Request
Bug description:  add optional parameter for line ending to fputcsv

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 bug report at http://bugs.php.net/?id=42357&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42357&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42357&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42357&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42357&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42357&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42357&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42357&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42357&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42357&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42357&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42357&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42357&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42357&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42357&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42357&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42357&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42357&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42357&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42357&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42357&r=mysqlcfg

Reply via email to