Monday, May 17, 2010

Carriage return and Line feed

If I work too much under Linux (x)or Windows and I want to switch to the other operating system I bump into the new line issue.

Here are the actors:

CR - carriage return, ASCII code 10 (or \r) - means that the printer carriage should return at the beginning of the line

LF - line feed, ASCII code 13 (or \n) - means that the printer carriage should be move on next line.

New line - whenever you need to move to a new line (in console or editor)


Windows and Linux treat that new line differently:

Window - the new line is made out of a CR and LF so actually the code for new line is CR+LF (\r\n)

Linux - the new line is a simple line feed = LF (\n)

No comments:

Post a Comment