From: ib at wupperonline dot de
Operating system: Windows 2000
PHP version: 4.3.4
PHP Bug Type: Filesystem function related
Bug description: fopen mode "r" not working properly
Description:
------------
Using mode "r" to fopen files under Windows doesn't open them in text mode
(as it should), but in binary mode, thus working exactly like "rb".
Reading these files, you'll get "\r\n" instead of "\n" for new line
character.
Surprisingly, fopen accepts mode "rt" which isn't documented but works as
"r" should. It opens in text mode and returns "\n" instead of "\r\n".
Reproduce code:
---------------
Create a file named dat.txt containing 4 bytes: "1", CR, LF, "2", LF.
$f = fopen("dat.txt", "r");
$d = fread($f, 1);
echo ord($d) . " ";
$d = fread($f, 1);
echo ord($d) . " ";
$d = fread($f, 1);
echo ord($d) . " ";
$d = fread($f, 1);
echo ord($d) . " ";
fclose($f);
Expected result:
----------------
49 10 50 10
Actual result:
--------------
49 13 10 50
--
Edit bug report at http://bugs.php.net/?id=27573&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27573&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27573&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27573&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27573&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27573&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27573&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27573&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27573&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27573&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27573&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27573&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27573&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27573&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27573&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27573&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27573&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27573&r=float