[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MacPerl cgi-script question



At 10:22 11-03-96, Charles B. Cranston wrote:
>You might try \r instead of \n on the theory that if \n
>which is LF on Unix is mapped to CR on the Mac (because
>the Mac standard is to use CR betwen lines) then the
>logical map for \r which is CR on Unix would be LF on
>the Mac.  At least this is what most Mac C compilers do...

I«m a bit vague on how it actually works, but it seems to me it *SHOULD*
work like this:
\n = local line end convention
\r = Carriage Return
\l = Linefeed

I just ran this though
printf "%x %x %x %x",ord "\n" ,ord "\l",ord "\r", ord "\f";

and got this result:
d 0 a c

:-(

Your best authority in these matters is always perl itself. Of course you
need the manpage for printf to get the formatting codes. %x is hex, %d is
decimal.

Once I«ve got K&R open, thought I«d mention the ansi standard states
explicitly that \n is "newline NL (LF)" and \r is "carriage return CR". As
far as I know "NL" is not an actual character, but rather refers to
whatever is the charcter used to signify newline in your locale. According
to this \r should be unambiguous.
No mention of \l :-(, though I think it«s a splendid idea, if I say so myself.

PS, a smart thing to do when working with textfiles from other platforms is
to transfer them as text, that way they«re converted to the local line end
convenion and you avoid such hassles.