RE: [PHP] What is new line? \n? \j? 13? 10? 15?
| From: | Maxim Maletsky | Date: | Fri, 08 Sep 2000 02:44:56 +0000 |
| Subject: | RE: [PHP] What is new line? \n? \j? 13? 10? 15? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15811@lists.php.net to get a copy of this message | ||
Thanks , this is very helpful,
I am looking for a 100% precise definition of newlines imputed into a form
on internet by several different OSes, Browsers...
Let's say that by ANSI 10, 13 I will catch most of the cases... but can
there be anything else?
Q2: how can I catch CR , LF , CRLF and the fourth (always forget it...) ?
Q3: what is better to define newlines in PHP: by it's ANSI equivalent (like
chr(10) , chr(13).. ) or I can define it by \n and be sure that all those
are included no matter what OS/Browser is ? (guess not...)
Q4: Personally, I believe you know this very well, What regex would you use
to catch a newline imputed by a user on internet when you have no idea of
his OS/Browser?
I would really appreciate your help..
I'm testing this thing for days already....
Thanks in advance, David.
-----Original Message-----
From: David Robley [mailto:huntsman@hermes.nisu.flinders.edu.au]
Sent: Friday, September 08, 2000 10:03 AM
To: Maxim Maletsky; 'Martin'
Cc: PHP General List. (E-mail)
Subject: RE: [PHP] What is new line? \n? \j? 13? 10? 15?
On Thu, 07 Sep 2000, Maxim Maletsky wrote:
> try to run this:
>
>
>
> for($i=0; $i<256; $i++)
> echo '<br>Caracter '.$i.'
> --><b>'.chr($i).'</b><--
> ';
>
>
>
> and you'll see that the only ANSI characters recognized as newlines by
both
> MAC and WIN are 12, and 13...
> but is it a standart so whatever your system is 10 and 13 will ALWAYS and
> THE ONLY be newlines, or perhaps on a different OS it will be a #123
instead
> 10.. ?
>
> This is a question ... yet unanswered to me ...
>
> Cheers!
You may be getting confused here between new line, or linefeed as it is
also known, and the end of line character[s].
First, you are making an incorrect assumption from the results produced by
your little routine above. In fact, ASCII 13 is a carriage return, and ASCII
12 is a form feed character, which may look the same as a carriage return
when printed to screen, but is a completely different kettle of fish :-)
These terms relate back to the days of line based printers and an era when
sometimes your only I/O to a computer was a teletype. Carriage Return
represented returning the print head to the beginning of the _current_ line
and Line Feed represented rolling the paper up to the next line without
returning the print head to the beginning of the line. Form feed of course
would feed paper through until the printer reached where it thought a new
page might begin.
Now for the end of line; this is represented differently in different OSes
by one or more of carriage return CR (ASCII 13) and line feed LF (ASCII 10).
MSDOS and its offspring use CR LF, unices use LF and I believe Mac uses CR.
Any more of this and I'd be lecturing :-) but that should put you on the
right track. You might want to grab a listing of ASCII codes and have a
look therein.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA