• Home
  • About
  • Sitemap
  • Search
Complete Coding
Subscribe to Complete Coding
Subscribe to Complete Coding

    The History Of Carriage Return Line Feed

    18th July 2010

    Most of us developers (especially Windows developers) wonder why an end-of-line is represented by <carriage return><line feed> in Windows text files. What does <carriage return> or <line feed> exactly mean?

    In the early stages before computers, there existed a device known as the TeleType. The TeleType contained a keyboard, printer, and paper tape reader/punch. It could transmit messages over telephones using a modem at a rate of 10 characters per second.

    TeleType

    But TeleType had a problem. It took 0.2 seconds to move the printhead from the right side to the left. 0.2 seconds is two character times. If a second character came while the printhead was in the middle of a return, that character was lost.

    The TeleType people solved this problem by making end-of-line two characters: <carriage return> to position the printhead at the left margin, and <line feed> to move the paper up one line. That way the <line feed> “printed” whilethe printhead was racing back to the left margin.

    When the early computers came out, some designers realized that using two characters for end-of-line wasted storage. Some picked <line feed> for their end-of-line, and some chose <carriage return>. Some of the die-hards stayed with the two-character sequence.

    Unix uses <line feed> for end-of-line. The newline character n is code 0xA (LF or <line feed>). MS-DOS/Windows uses the two characters <carriage return><line feed>. So if you are transferring text files from a Unix machine to Windows, you have to use some conversion utility eg. unix2dos for stripping the <carriage return> character from the files.

    Further reading:
    How do I convert between Unix and Windows text files?
    Newline Character

    Related Posts:

    • Programming Is About Doing The Job Right
    • The Ten Commandments for C++ Programmers
    • C++ Pitfall: Beware of Dangling References
    • Five Websites to Download Open Source Software
    • Three Pitfalls To Avoid When Using Dynamically Allocated Memory
    Author : kevin | My Website

    {One comments... read them below or add one}
      Leave a Comment
      Click here to cancel reply.

      Click to cancel reply

      « Previous Article Next Article »

      Recent Posts

      • Did We Pass On The Joel Test?
      • Programming Is About Doing The Job Right
      • How should I decide on the programming language to learn next?
      • How To Handle Errors In Google Go
      • How To Achieve Concurrency In Google Go
      Complete Coding Categories
      • development
      • general
      • programming
      • programs
      • today's read
      © 2010-2011 Kevin Rodrigues.