ID:               32090
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ceefour at gauldong dot net
-Status:           Open
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: Windows XP SP1
 PHP Version:      5.0.3
 New Comment:

Please provide a complete test case; most of these so called bug
reports are due to the person viewing the data using the wrong tools.

FYI: "text mode" is an evil invention that usually leads to trouble. 
It is generally better for the programmer to be explicit with their
line endings, as it leads to a lower WTF? factor.


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

[2005-02-24 00:10:09] ceefour at gauldong dot net

BTW, for *PORTABILITY* I choose 't' (text mode), so it works both for
UNIXes and Windows, even MACs.

I don't want to do this:
fopen(...., 'wb')
if (strpos('win', strtolower(PHP_OS)) !== false) {
  $line_ending = "\r\n";
} else {
  $line_ending = "\n";
}

which is NOT PORTABLE AT ALL. Why do you suggest 'b' mode will be more
portable? The documentation is weird, IMHO.

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

[2005-02-24 00:02:06] ceefour at gauldong dot net

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

Reply via email to