CRLF CRLF

CRLF - Definition and Overview

CRLF is a sequence of control characters consisting of a carriage return (CR) and a line feed (LF). The CRLF sequence is the newline separator for text files in Microsoft Windows and related operating systems. It is also the standard line separator for most Internet protocols.

Contents

Operating system differences

The use of the CRLF causes portability problems when trying to move text files between Windows, Unix, and Macintosh computers :

  • Windows uses the CRLF;
  • Unix and Mac OS X use only LF;
  • and the Macintosh before Mac OS X uses only CR.

Recognising and fixing incompatibilities

  • When a Unix or Macintosh text file is displayed on a Windows machine, it appears as one long line with strange characters where the line breaks should be, often appearing as black rectangles
  • When a Windows text file is displayed on a Unix or Mac OS X machine, every line appears to end with a superfluous CR, which often appears as ^M
  • When a Windows text file is displayed on a pre-Mac OS X Macintosh, every line appears to begin with a superfluous LF.

Some software will automatically compensate for incompatible line endings, but other software will not. When dealing with text files that are not in the correct format for your operating system, it helps to have a program that can correct them. For example, Notepad, the standard plain text editor pre-installed on all Windows machines does not automatically convert Unix or Macintosh text files, but the DOS edit command (also pre-installed on all Windows machines) does convert Unix or Macintosh style CR line endings and allows to re-save the file with Windows-style CRLF line endings.

History

It has been speculated that QDOS (which Microsoft purchased and renamed MS-DOS) adopted CR+LF to indicate a newline to copy the implementation used by CP/M. Further speculation indicates that CP/M chose CR+LF to introduce a deliberate incompatibility with Unix to mitigate a possible lawsuit by AT&T/Bell over violating their Unix copyrights as CP/M was loosely modeled on Unix.

See also

  • ASCII
  • Text editor
  • tofrodos (http://www.thefreecountry.com/tofrodos/index.shtml) is a program for Unix and Windows to convert between these formats
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.