ID: 41609
User updated by: zoe at uk dot ibm dot com
Reported By: zoe at uk dot ibm dot com
-Status: Open
+Status: Closed
Bug Type: Filesystem function related
Operating System: Windows XP
PHP Version: 6CVS-2007-06-06 (snap)
New Comment:
Yes - you are right. The FILE_BINARY flag does fix the problem. I'm
closing this.
Previous Comments:
------------------------------------------------------------------------
[2007-06-09 21:17:40] [EMAIL PROTECTED]
"when files are not opened with the binary flag, windows automatically
converts \n to \r\n. I don't have time until mid-July to investigate
this problem though."
As far as I remember, it is the documented behavior (windows file
functions).
It is especially important to take care of text contents in the unicode
mode, it is not a good idea to blindly save everything as binary. That's
why php6 has two new flags which can be used in file_put_contents:
- FILE_TEXT, opens with "wt" (or "at" if FILE_APPEND is used)
- FILE_BINARY, opens with "wb" (or "ab"
the default mode is "w", which is a text mode on windows.
I do not have a windows at hand to test but I'm pretty sure that
FILE_BINARY solves your issue. It may use it automatically when a binary
string is given, but I would find that trickier (magic++).
------------------------------------------------------------------------
[2007-06-09 21:03:19] [EMAIL PROTECTED]
when files are not opened with the binary flag, windows automatically
converts \n to \r\n. I don't have time until mid-July to investigate
this problem though.
------------------------------------------------------------------------
[2007-06-06 10:48:09] zoe at uk dot ibm dot com
Hi Johannes
No, it doesn't:
E:\zoe\TESTS\slashr>e:\zoe\buildsystem\php6exe\php.exe -d
unicode.semantics=0 johannes.php
string(7) "foo
bar"
E:\zoe\TESTS\slashr>e:\zoe\buildsystem\php6exe\php.exe -d
unicode.semantics=1 johannes.php
string(7) "foo
bar"
------------------------------------------------------------------------
[2007-06-06 10:26:31] [EMAIL PROTECTED]
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?
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/41609
--
Edit this bug report at http://bugs.php.net/?id=41609&edit=1