|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a user input form that allows them to provide a description of
their request. Unfortunately when downloading and processing the data their carriage returns \line feeds cause problems. It is php on a Linux machine. I've tried the following: $comment = nl2br($comment); $comment = str_replace("<br>"," ",$comment); And this $order = array("\r\n", "\n", "\r"); $replace = ' '; $comment = str_replace($order, $replace, $comment); And this $comment = str_replace("\r"," ",$comment); $comment = str_replace("\n"," ",$comment); but the output in the file always has a '^M' where the linefeed would be: 999~05/25/2008~05/26/2008~3~test 3 after^M before~argh!~A Anyone know how to cleanly remove the offending CRLF Thanks! Jon |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
The textbox or other input form,
does not use either \n or <br> it is text and carriage returns are represented by Ctrl-M (^M decimal character 13 Hex 0D) linefeeds are implied by carriage returns in many systems but are otherwise represented by Ctrl-A (^A decimal character 10, hex 0A) You could replace hex 
, ^M, instead of \n <br> which are not present in the data to be replaced, the php to replace the control character is beyond me at 2 in the morning -- Adaware http://www.lavasoft.de spybot http://www.safer-networking.org AVG free antivirus http://www.grisoft.com Etrust/Vet/CA.online Antivirus scan http://www3.ca.com/securityadvisor/virusinfo/scan.aspx Panda online AntiVirus scan http://www.pandasoftware.com/ActiveScan/ Catalog of removal tools (1) http://www.pandasoftware.com/download/utilities/ Catalog of removal tools (2) http://www3.ca.com/securityadvisor/n...aspx?CID=40387 Blocking Unwanted Parasites with a Hosts file http://mvps.org/win2002/hosts.htm links provided as a courtesy, read all instructions on the pages before use Grateful thanks to the authors and webmasters _ <bulldog8@lycos.com> wrote in message news:3a0e0dba-0e30-4d3c-b477-e33f067892ff@a23g2000hsc.googlegroups.com... > I have a user input form that allows them to provide a description of > their request. Unfortunately when downloading and processing the data > their carriage returns \line feeds cause problems. > > It is php on a Linux machine. I've tried the following: > > $comment = nl2br($comment); > $comment = str_replace("<br>"," ",$comment); > > And this > > $order = array("\r\n", "\n", "\r"); > $replace = ' '; > $comment = str_replace($order, $replace, $comment); > > And this > > $comment = str_replace("\r"," ",$comment); > $comment = str_replace("\n"," ",$comment); > > but the output in the file always has a '^M' where the linefeed would > be: > > 999~05/25/2008~05/26/2008~3~test 3 after^M > before~argh!~A > > > Anyone know how to cleanly remove the offending CRLF > > Thanks! > Jon |
|
![]() |
| Outils de la discussion | |
|
|