|Integer ASCII code:||10|
|Binary code:||0000 1010|
|C/C++ notation:||\n or '\n'|
Unicode symbol: ␊, int code: 9226 (html ␊) hex code: 240A (html ␊)
On typewriters, printers, and some terminal emulators, line feed has a function of moving the cursor down one row without producing any effect on its column position. On Unix it is used to mark end-of-line. In DOS, Windows, and different network standards, line feed is used following CR as part of the end-of-line mark.
Newline (often called line ending, end of line (EOL), line feed, or line break) is a control character or sequence of control characters in a character encoding specification (e.g. ASCII or EBCDIC). It is used in function of symbolizing the end of a line of text and the following start of a new one. This special character is set by text editors with the help of Enter key.
When showing (or printing) a text file, this control character makes the text editor to show the following characters in a new line.
In the mid-1800s, Morse code operators invented and used Morse code prosigns in order to encode white space text formatting in formal written text messages. This happened long before the creation and usage of teleprinters and teletype machines. Especially, the Morse prosign was represented by the adhesion of two literal textual Morse code "A" characters. They were sent without the usual inter-character spacing, which was used in Morse code in order to encode and indicate a new line in a formal text message.
Now let's move further. Some time later, when the modern teleprinters were created and standardized, character set control codes were developed just to provide help in white space text formatting. ASCII was developed by the International Organization for Standardization (ISO) and the American Standards Association (ASA) at a time. The American Standards Association (ASA) was actually the predecessor organization to American National Standards Institute (ANSI). The period of 1963 to 1968 was a significant one, because it was the time when ISO draft standards supported the use of CR+LF or LF alone as a newline. However, the ASA drafts supported only CR+LF.
The CR+LF sequence was commonly used on many early computer systems that had adopted Teletype machines. A Teletype Model 33 ASR was an outstanding console device, because this sequence was required to position those printers at the start of a new line. The split of newline into two functions, however, hid the fact that if the print head was far away, it could not return to the beginning of the next line in one-character time. That is the reason of why the sequence was always sent with the CR first. A character printed after a CR would often print not correctly, leaving an unplanned and pretty unpleasant blot in the middle of the page, while it was still moving the carriage back to the first position. The solution was to make the newline with the help of two characters: CR to move the carriage to column one, and LF to move the paper upwards. Actually there was often a necessity in sending extra characters (unnecessary CRs or NULs, which are ignored) to give the print head some time to move to the left margin. Even many video displays of past time needed multiple character times in order to scroll the display.
These systems were arranged the way, which required text to be constantly arranged in order to be compatible with these printers. The key was that the concept of device drivers, concealing such hardware details from the application, was not yet well developed. This way, applications had to talk directly to the Teletype machine and follow its conventions. Lots of minicomputer systems from DEC used this convention. CP/M used it too in order to print on the same terminals that minicomputers used. That was the time, when MS-DOS (1981) adopted CP/M's CR+LF in order to be compatible. This convention was taken over by Microsoft's later Windows operating system.
In 1964 Multics operating system began development. LF played a role of its newline, so LF was used alone. Multics used a device driver in order to reformulate this character to any sequence that a printer required (including extra padding characters), and the single byte was more convenient for programming. Nowadays we think that there was much more easy and obvious choice of CR, however, it was not used. The reason is the following: a simple CR provided the helpful function of overprinting one line with another. With the help of it some boldfaces and strikethrough effects could be created, thus it was useful to not translate it. There is one fact that is actually the most important one: the use of LF alone as a line terminator had already been incorporated into drafts of the final ISO/IEC 646 standard. Unix did the same what Multics did, and later Unix-like systems followed Unix.
People closely associate ideas concepts of line feed (LF) and carriage return (CR). They can be considered either separately or together. If we're talking about the physical media of typewriters and printers, two axes of motion, "down" and "across", are necessary here in order to create a new line on the page. Despite the fact, that the design of a machine (typewriter or printer) must consider them separately, the mechanical logic of software can unite them together as one thing. This is the reason why a newline in character encoding can be defined as LF and CR united into one (usually called CR+LF or CRLF).
Some sets of character have an individual newline character code. Let's see the example. EBCDIC has an NL character code in addition to the existing CR and LF codes. Unicode also supports a "next line" (NEL) control code and some control codes for "line separator" and "paragraph separator" markers in addition to providing the ASCII CR and LF control codes.
|input value||base||type||output hash|