history (was Re: datainput stream)

From: Nate Smith (greystone_at_NET1Plus.com)
Date: 12/11/03


Date: Thu, 11 Dec 2003 13:01:38 -0500

Amey Samant wrote:

> i will also keep in mind about the '\n' and '\r' on win while only
> '\n' on nix

  it's interesting how windows terminates each line with
  the \r\n sequence rather than unix's simpler \n.

  the origin of the \r\n sequence dates way back to the
  old FORTRAN days and teletype machines and lineprinters
  that had lots & lots of mechanical parts. FORTRAN used
  to close a line with CR LF but quickly they changed it
  to CR CR LF because the machinery would get dirty & stick
  & not complete a carriage return. the simple fix then
  was to send a duplicated \r or CR, because this wouldnt
  change the appearance & got rid the mechanical problem
  in all but a few acceptably rare cases. later, when
  the CR LF combo was combined into the newline character,
  \n, the world split into 2 camps. the unix dudes, who
  noted that the old mechanical problems of the past were
  no longer a factor, opted to save a char by dropping the
  \r. the windows dude kept loyal to the dinosaurian
  method and came up with the CR \n sequence.

  in the old days of teletype communications there were
  guys stationed around the world to would send messages
  to each other (infact there still are!). sometimes,
  bored with sitting at the terminal on the graveyard
  shift, guys might send a messages to each other's
  typewriters along these lines:

    1st guy: "HEY JOE - HOW ARE YOU?"
    2nd guy: "HI BOB - PRETTY GOOD. NOTHING
               GOING ON HERE"
    1st guy: "I SNUCK IN MY HONEY TONIGHT.
               GUESS WHAT WE'RE DOING RIGHT NOW!"
    2nd guy: "WHAT?"
    1st guy" "<SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>
               <SHIFTLOCK><F><SHIFTOFF><f>"

- nate