SPUG: Removing special characters

Fred Morris m3047 at inwa.net
Mon Apr 3 10:06:26 PDT 2006


A.k.a. "CR". Typically it is paired with a newline (a.k.a. "LF"): CRLF,
^M^J or \r\n.

Usually found in all application layer networking protocols: HTTP, SMTP,
etc. A lot of applications may accept either the CR or LF alone (more often
the LF than the CR), but it's bad form to send data that way. (QMail comes
to mind as one MTA which is particularly annoying in its regard of bare
LFs.)

Historically this goes back to hardware control, where the LF kicked the
paper and the CR moved the printing head (ahhh, nostalgia!).

Common problem is that people break traffic coming over the wire on the LF,
and find the CR still stuck to the end of the lines. Best practice
alternative to chomp might be something like (untested):

  s/\r?\n//o

I note that most software native to whatever platform handles this
automagically, converting what comes over the wire into "native" format,
whether that's LF, CR, or CRLF (but don't get me started about EBCDIC!).

At 8:41 AM 4/3/06, mike wrote:
>
>try
>
>\r
>
>its a carraige return
>
>usually found in windows land

--

Fred Morris
http://www.inwa.net/~m3047/contact.html




More information about the spug-list mailing list