Integer ASCII code: | 10 |
Binary code: | 0000 1010 |
Octal code: | 12 |
Hexadecimal code: | 0A |
Group: | control |
Seq: | ^J |
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 | output hash |
---|---|---|
LF | char | 68B329DA9893E34099C7D8AD5CB9C940 |
10 | dec | D3D9446802A44259755D38E6D163E820 |
00001010 | bin | 96DA9783406F8319C3430EADBEC0657A |
0000 1010 | bin | 8FFF37AFAA968C5BF1F04A6086EC61AD |
12 | oct | C20AD4D76FE97759AA27A0C99BFF6710 |
0A | hex | 3EE74005E9165BAC449DCBE722951CE0 |
0x0A | hex | 203809897978968515F4CE00FCBB035D |
input value | base | output hash |
---|---|---|
LF | char | 01BA4719C80B6FE911B091A7C05124B64EEECE964E09C058EF8F9805DACA546B |
10 | dec | 4A44DC15364204A80FE80E9039455CC1608281820FE2B24F1E5233ADE6AF1DD5 |
00001010 | bin | 6A131909034F7E8821E3AEB96C33309CDC99A3BBF0ABBBEFA9F650060B488B7A |
0000 1010 | bin | 3D78CE0E9B9892BA7000AC23BBC1C3426DEBCA26FD39B9D15D96144B175911E5 |
12 | oct | 6B51D431DF5D7F141CBECECCF79EDF3DD861C3B4069F0B11661A3EEFACBBA918 |
0A | hex | 03A51BD6760F743E8FE6EA0488A26C58043FC41DD54B7DD606E585084B280A2B |
0x0A | hex | AF2D2BF9DFCA0CE288E2AB9894EF77FE3F1214AFFC00B3395C850C888CC360C5 |
input value | base | output hash |
---|---|---|
LF | char | Cg== |
10 | dec | MTA= |
00001010 | bin | MDAwMDEwMTA= |
0000 1010 | bin | MDAwMCAxMDEw |
12 | oct | MTI= |
0A | hex | MEE= |
0x0A | hex | MHgwQQ== |