Difference Between Carriage Return and Line Feed

What's the difference between carriage return (CR) and line feed (LF)?

Carriage Return (CR) means return to the beginning of the line. It tells a Teletype machine to bring the print head back to the left. CR is represented by ASCII code 13.

Line Feed (LF) tells a printer to move the paper up 1 line. It's ASCII code 10

Both commands terminate a line of text and start on a new line.  But different operating systems have their own way of handling the use of LF and/or CR. Windows ends all lines in text files with CR LF, with CR taking precedence. Meanwhile, Unix uses only LF. To top it all off, Mac terminates lines with the CR character. This means Mac, Unix, and Windows text documents are all going to be a bit different and at times incompatible.  You can use a text file editor such as Notepad++ to view end of lines to make any changes if the difference is breaking a process.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.