|  | |  |
01-13-2004, 10:32 AM
|
#1 (permalink)
| | $_['Your_Mom'];
Join Date: May 2002 Location: Santee
Posts: 627
| MAC new line? i have a <textarea> input field i am using to collect userdata. when i am parsing through the data, most text (windows & linux) is just fine. however, when a MAC user submits something its just 1 big bunch of text. i am replacing "\n" with "<br>" when displaying the text.
do macs send newlines in a different format?
i havent looked anywhere else, just figured someone on here would konw. |
| |
01-13-2004, 11:41 AM
|
#2 (permalink)
| | LOAD "*",8,1
Join Date: Feb 2003 Location: la.ca.us
Posts: 254
| for newlines:
unix uses linefeed ('\n')
macs use carriage return ('\r')
windows uses carriage return + linefeed ('\r\n')
however, some browsers may do translations of text fields. |
| |
01-13-2004, 02:48 PM
|
#3 (permalink)
| | $_['Your_Mom'];
Join Date: May 2002 Location: Santee
Posts: 627
| Thanks! I will check out the \r route tonight. |
| |
01-13-2004, 05:30 PM
|
#4 (permalink)
| | $_['Your_Mom'];
Join Date: May 2002 Location: Santee
Posts: 627
| Is there a standard way for me to replace all new lines with a different character? I simply changed my \n to \r but want to make sure this works for EVERYONE not just Windows and Mac. I need to implement something that takes everything info account. |
| |
01-13-2004, 05:52 PM
|
#5 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
| \n\r ?
__________________ Mike |
| |
01-13-2004, 08:44 PM
|
#6 (permalink)
| | $_['Your_Mom'];
Join Date: May 2002 Location: Santee
Posts: 627
| here is what I have now. PHP Code: //this really come out of the database
//but you get the idea
$foo = "this is something
this is something else
cool
sweet
yess
noooo";
$foo = explode("\r","$foo");
//do some stuff to that array here
when i 'explode' the string, i want it to work out for all cases of a new line (\n,\r,\n\r) |
| |
01-13-2004, 09:22 PM
|
#7 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
| will \n\r work for both pc/mac ? if so, i'd do something like this: PHP Code: <?
$string = str_replace("\\n","{newline}",$string);
$string = str_replace("\\r","{newline}",$string);
$string = str_replace("{newline}","\\r\\n",$string);
?>
__________________ Mike |
| |
01-13-2004, 09:34 PM
|
#8 (permalink)
| | LOAD "*",8,1
Join Date: Feb 2003 Location: la.ca.us
Posts: 254
| Quote: Originally posted by sde will \n\r work for both pc/mac ? if so, i'd do something like this: PHP Code: <?
$string = str_replace("\n","{newline}",$string);
$string = str_replace("\r","{newline}",$string);
$string = str_replace("{newline}","\r\n",$string);
?> | close. change the order and it works fine. PHP Code: <?
$string = str_replace("\r\n","{newline}",$string);
$string = str_replace("\n","{newline}",$string);
$string = str_replace("\r","{newline}",$string);
?> |
| |
01-13-2004, 09:38 PM
|
#9 (permalink)
| | $_['Your_Mom'];
Join Date: May 2002 Location: Santee
Posts: 627
| thanks joe, that looks like it will work perfect! |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -8. The time now is 08:32 PM. |
Copyright © 2000-2008, Milano Interactive Web Hosting provided by Portal 360 Web Hosting |  | |