RE: [PHP] What is new line? \n? \j? 13? 10? 15?
| From: | David Robley | Date: | Fri, 08 Sep 2000 02:48:32 +0000 |
| Subject: | RE: [PHP] What is new line? \n? \j? 13? 10? 15? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15814@lists.php.net to get a copy of this message | ||
On Fri, 08 Sep 2000, Maxim Maletsky wrote:
> 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.
1) I think you really mean End of Line markers now; there is only one
definition of a newline and that is the character variously represented by
ASCII 10, \n, hex 0A etc.
2) Basically, you only need to test for the existence of CR and/or LF and
do what you will if found.
3) Depends on which of PHPs functions you are using and whether they
understand the chosen option. Perhaps you might want to read up on chapter
6 of the manual on Types and the list of escaped characters.
4) Erm, my knowledge of regex is pretty pitiful, I'm afraid. If all you
want to do is get rid of them, you probably should use str_replace or
substr_replace to replace them with a '' (null, in single quotes) something
like
$val = str_replace('\n','',$val);
$val = str_replace('\r','',$val);
might do the trick.
-- 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