From:             zoe at uk dot ibm dot com
Operating system: Windows XP
PHP version:      6CVS-2007-06-06 (snap)
PHP Bug Type:     Unicode Function Upgrades related
Bug description:  file_put_contents() injects \r

Description:
------------
A file created on Windows using file_put_contents in PHP6 has different
contents if unicode.semantics=1 is used.

The files (data.tmp) created by the test case below have different
contents, from "od -x" it looks to me as though an additional \r is
inserted in the file before the \n.






Reproduce code:
---------------
<?php
$file_path = dirname(__FILE__);
$buffer = "text\nline of text\n";
file_put_contents( $file_path."/data.tmp", (binary)$buffer);

$fp = fopen($file_path."/data.tmp", "r");
var_dump( file_get_contents($file_path."/data.tmp") );
fclose($fp);

$fp = fopen($file_path."/data.tmp", "r");
var_dump( fgets($fp) );
fclose($fp);

$fp = fopen($file_path."/data.tmp", "rb");
var_dump( fgets($fp) );
fclose($fp);

$fp = fopen($file_path."/data.tmp", "rt");
var_dump( fgets($fp) );
fclose($fp);

?>

Expected result:
----------------
string(18) "text
line of text
"
string(5) "text
"
string(5) "text
"
string(5) "text
"

Actual result:
--------------
string(20) "text
line of text
"
string(6) "text
"
string(6) "text
"
unicode(5) "text
"

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

Reply via email to