ID:               41609
 Updated by:       [EMAIL PROTECTED]
 Reported By:      zoe at uk dot ibm dot com
 Status:           Open
 Bug Type:         Filesystem function related
 Operating System: Windows XP
 PHP Version:      6CVS-2007-06-06 (snap)
 New Comment:

I'd assume this is some ICU feature when converting a text with
newlines from UTF-8 to UTF-16 and then back to UTF-8.

Does something like
<?php
$a = "foo\nbar";
var_dump((binary)$a);
?>
also show the \r?


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

[2007-06-06 09:35:57] [EMAIL PROTECTED]

No, thanks. This should be enough for somebody who knows how to debug
it on Windows. 
Unfortunately, I don't.

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

[2007-06-06 08:56:30] zoe at uk dot ibm dot com

Hi - sorry - I should have mentioned that the behaviour is not
reproducible on Linux. It's Windows specific. Would you like the copies
of the data.tmp files that are created in each case? - if so I'll attach
them to this.

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

[2007-06-06 08:38:47] [EMAIL PROTECTED]

Could you plz try the same on Linux?
I can't replicate it there.

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

[2007-06-06 08:08:15] zoe at uk dot ibm dot com

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 this bug report at http://bugs.php.net/?id=41609&edit=1

Reply via email to