From:             ceefour at gauldong dot net
Operating system: Windows XP SP1
PHP version:      5.0.3
PHP Bug Type:     Filesystem function related
Bug description:  fopen(..., 'wt') - fwrite($fp, ...) translates \n to \r

Description:
------------
Using 'wt' (write-text), any \n should be translated to \r\n (0D 0A).

However in my system, PHP 5.0.3 in Windows XP SP1, this mode translates \n
to \r only (0D), which results in MAC-style line endings.

I had to use 'wb' (write-binary) and put \r\n manually to get desired
results.

Reproduce code:
---------------
$fp = fopen('anyfile.txt', 'wt');
fwrite($fp, "Hello\n");
fclose($fp);

Expected result:
----------------
anyfile.txt contains "Hello" + 0D 0A (\r \n)

Actual result:
--------------
anyfile.txt contains "Hello" + 0D (\r only)

-- 
Edit bug report at http://bugs.php.net/?id=32090&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32090&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32090&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32090&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32090&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32090&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32090&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32090&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32090&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32090&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32090&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32090&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32090&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32090&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32090&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32090&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32090&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32090&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32090&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32090&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32090&r=mysqlcfg

Reply via email to