RE: [PHP-DEV] PHP 4.0 Bug #5646: fwrite() in CGI php.exe doesn't make a CR/LF for "\n" but just a linefeed char

From: Date: Tue, 18 Jul 2000 14:30:21 +0000
Subject: RE: [PHP-DEV] PHP 4.0 Bug #5646: fwrite() in CGI php.exe doesn't make a CR/LF for "\n" but just a linefeed char
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-24939@lists.php.net to get a copy of this message
Well either way I don't really care whether \n is cr/lf or if you need to make it \r\n. But it should be consistant. I should not have to change my script whenever I switch from ISAPI to CGI mode or vice versa. joel@intwebservices.com At 11:09 PM 7/17/00 -0600, you wrote:
1) Even if I agreed with this broad interpretation of the word "newline", the bug would not (IMO) be in PHP, but in Win32's stdio imp. According to this table the platform's IO lib. should transfer "\n" into "CRLF" (on any DOS based platforms), not user-space applications. 2) I disagree with this line of reasoning completely. \n == newline == linefeed == == \012 == \x0A == \cJ == ASCII 10. CRLF is NEVER == newline...it is 2 ascii chars, and should be thought of as such. I personally don't want PHP to do kludgy stuff like this. If I want files to have \r\n as the line terminator, by golly, I'll code my application that way. Either way, fwrite() is just a wrapper to the OS's fwrite(). If \n _WERE_ supposed to be replaced by CRLF, it should be at the OS level. Since the OS does not appear to be doing it, it probably should not happen at all. This comes from the URL you mentioned: "In DOSish perls, \n usually means \012, but when accessing a file in ``text'' mode, STDIO translates it to (or from) \015\012, depending on whether you're reading or writing." On Mon, 17 Jul 2000, joel@intwebservices.com wrote the following to Powell,Tim : Well I did a bit of checking about that on the web. \n is a newline.
        Wrong. By your own table, \n is LF, on ALL PLATFORMS, unless
re-written by that platform's IO lib. Here is what I found from a Perl reference at: http://www.google.com/search?q=cache:www.activestate.com/ActivePerl/docs/lib /Pod/perlport.html+cr/lf+windows+unix+convention+rule&hl=en --------------------- In most operating systems, lines in files are terminated by newlines. Just what is used as a newline may vary from OS to OS. Unix traditionally uses \012, one type of DOSish I/O uses \015\012, and Mac OS uses \015.
    LF  ==  \012  ==  \x0A  ==  \cJ  ==  ASCII 10
     CR  ==  \015  ==  \x0D  ==  \cM  ==  ASCII 13
              | Unix | DOS  | Mac  |
         ---------------------------
         \n   |  LF  |  LF  |  CR  |
         \r   |  CR  |  CR  |  LF  |
         \n * |  LF  | CRLF |  CR  |
         \r * |  CR  |  CR  |  LF  |
         ---------------------------
         * text-mode STDIO
----------------------------------------------------------------- Since this is about the PHP CGI for Windows it is my understanding that the windows convention for a Newline \n is CR/LF for text mode IO.
        Again, you are confusing yourself.
        Just because Perl does a workaround for this (in their Socket
module, not even in the core language) does not necc. mean we should...
        BTW, has anyone actually even seen a platform where \r != \015 or
\n != \012? -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.dev (#24939) next »