|
In computing, a newline is a special character or sequence of characters signifying the end of a line of text. The name comes from the fact that the next character after the newline will appear on a new line — that is, on the next line below the text immediately preceding the newline. The actual codes representing a newline vary across hardware platforms and operating systems, which can be problematic when exchanging data between systems of different types. Memory (Random Access Memory) Look up computing in Wiktionary, the free dictionary. ...
There is also some confusion as to whether newlines terminate or separate lines. If a newline is considered a separator, there will be no newline after the last line of a file. The general convention on most systems is to add a newline even after the last line, i.e. to treat newline as a line terminator. Some programs have problems processing the last line of a file if it isn't newline terminated. Conversely, programs that expect newline to be used as a separator will interpret a final newline as starting a new (empty) line. This can result in a different line count being reported for the file, but is generally harmless otherwise. Newlines are also sometimes called line breaks or end-of-line (EOL) characters. Representations
Software applications and operating systems usually represent a newline with one or two control characters: An operating system (OS) is a set of computer programs that manage the hardware and software resources of a computer. ...
In computing, a control character or non-printing character, is a code point (a number) in a character set that does not, in itself, represent a written symbol. ...
- Systems based on ASCII or a compatible character set use either LF (Line feed, 0x0A) or CR (Carriage Return, 0x0D) individually, or CR followed by LF (CR+LF, 0x0D 0x0A); see below for the historical reason for the CR+LF convention. These characters are based on printer commands: The line feed indicated that one line should feed out of the printer, and a carriage return indicated that the printer carriage should return to the beginning of the current line.
- LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, etc.), BeOS, Amiga, RISC OS, and others
- CR+LF: DEC RT-11 and most other early non-Unix non-IBM OSes, CP/M, MP/M, MS-DOS, OS/2, Microsoft Windows
- LF+CR: Daisy Systems Daisy-DNIX (obsolete)
- CR: Commodore machines, Apple II family and Mac OS up to version 9
- EBCDIC systems—mainly IBM mainframe systems, including z/OS (OS/390), i5/OS (OS/400)—use NEL (Next Line, 0x15) as the newline character. Note that EBCDIC also has control characters called CR and LF, but the numerical value of LF differs from the one used by ASCII. Additionally, there are some EBCDIC variants that also use NEL but assign a different numeric code to the character.
- CDC NOS used at least 4 six-bit characters with the character code 00 at the end of a 60-bit word to indicate end-of-line. Character code 00 was also used to represent the colon character; thus if you entered too many consecutive ":" characters with the CDC text editor, you might unintentionally create an extra end-of-line!
- OpenVMS uses a record-based file system which stores text files as one record per line. In most file formats, no line terminators are actually stored, but the Record Management Services facility can transparently add a terminator to each line when it is retrieved by an application.
- Fixed line length was used by some early mainframe operating systems. In such a system, an implicit end-of-line was assumed every, say, 80 characters. No newline character was stored. If a file was imported from the outside world, lines shorter than the line length had to be padded with spaces, while lines longer than the line length had to be truncated. This mimicked the use of punched cards, on which each line was stored on a separate card, usually with 80 columns on each card.
Most textual Internet protocols (including HTTP, SMTP, FTP, IRC and many others) mandate the use of ASCII CR+LF (0x0D 0x0A) on the protocol level, but recommend that tolerant applications recognize lone LF as well. In practice, there are many applications that erroneously use the C newline character 'n' instead (see section Newline in programming languages below). This leads to problems when trying to communicate with systems adhering to a stricter interpretation of the standards; one such system is the qmail MTA that actively refuses to accept messages from systems that send bare LF instead of the required CR+LF. There are 95 printable ASCII characters, numbered 32 to 126. ...
In mathematics and computer science, hexadecimal, base-16, or simply hex, is a numeral system with a radix, or base, of 16, usually written using the symbols 0â9 and AâF, or aâf. ...
Originally, carriage return was the term for the key, lever, or mechanism on a typewriter that would cause the cylinder on which the paper was held (the carriage) to return to the left side of the paper after a line of text had been typed, and would often move it...
Multics (Multiplexed Information and Computing Service) was an extraordinarily influential early time-sharing operating system. ...
Filiation of Unix and Unix-like systems Unix (officially trademarked as UNIX®) is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T employees at Bell Labs including Ken Thompson, Dennis Ritchie and Douglas McIlroy. ...
GNU (pronounced ) is a computer operating system - consisting of a kernel, libraries, system utilities, compilers, and end-user application software - composed entirely of free software. ...
Linux (IPA pronunciation: ) is a Unix-like computer operating system family. ...
AIX (Advanced Interactive eXecutive) is a proprietary operating system developed by IBM based on UNIX System V. Before the product was ever marketed, the acronym AIX originally stood for Advanced IBM UNIX. AIX has pioneered numerous network operating system enhancements, introducing new innovations later adopted by Unix-like operating systems...
Xenix was a version of the Unix operating system, licensed by Microsoft from AT&T in the late 1970s. ...
Mac OS X (official IPA pronunciation: ) is a line of proprietary, graphical operating systems developed, marketed, and sold by Apple Inc. ...
BeOS is an operating system for personal computers which began development by Be Inc. ...
The original Amiga 1000 (1985) with various peripherals The Amiga is a family of home/personal computers originally developed by Amiga Corporation as an advanced home entertainment and productivity machine. ...
This article or section does not cite its references or sources. ...
DEC, dec or Dec may refer to: December - a month of the year in the Gregorian Calendar Department of Environment and Conservation Digital Equipment Corporation - a computer and technology company, now part of HP Declination - a term from astronomy Diethylcarbamazine - a drug commonly used to treat infections by filarial parasites...
RT-11 (for Run Time or Real Time) was a real-time operating system for the DEC PDP-11. ...
CP/M was an operating system originally created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc. ...
MP/M was the multi-user version of the CP/M operating system, created by Digital Research. ...
Microsofts disk operating system, MS-DOS, was Microsofts implementation of DOS, which was the first popular operating system for the IBM PC, and until recently, was widely used on the PC compatible platform. ...
To meet Wikipedias quality standards, this article or section may require cleanup. ...
Microsoft Windows is the name of several families of proprietary software operating systems by Microsoft. ...
Daisy Systems Corporation incorporated in 1981 in Mountain View, California, was a Computer-aided engineering company, a pioneer in the Electronic design automation (EDA) industry. ...
Commodore, the commonly used name for Commodore International, was an American electronics company based in West Chester, Pennsylvania which was a vital player in the home/personal computer field in the 1980s. ...
The 1977 Apple II, complete with integrated keyboard, color graphics, sound, a plastic case and eight expansion slots. ...
Logo: Mac OS System 7, 8 and 9 On January 24th, 1984 Apple Computer introduced the Apple Macintosh personal computer, with the Macintosh 128K model, which came bundled with the Mac OS operating system. ...
Sherlock 2 for Mac OS 9 with the new metallic appearance Mac OS 9, introduced by Apple Computer on 1999-10-23, is the last version of the Classic Macintosh Operating System (Mac OS) released before being succeeded by Mac OS X. Upon introduction, Mac OS 9 was advertised as...
EBCDIC (Extended Binary Coded Decimal Interchange Code) is an 8-bit character encoding (code page) used on IBM mainframe operating systems, like z/OS, OS/390, VM and VSE, as well as IBM minicomputer operating systems like OS/400 and i5/OS. It is also employed on various non-IBM...
International Business Machines Corporation (IBM, or colloquially, Big Blue) (NYSE: IBM) (incorporated June 15, 1911, in operation since 1888) is headquartered in Armonk, New York, USA. The company manufactures and sells computer hardware, software, and services. ...
z/OS Welcome Screen seen through a terminal emulator The title of this article begins with a capital letter due to technical limitations. ...
OS/390 is an IBM operating system for the System/370 and System/390 IBM mainframe computers. ...
OS/400 is an operating system used on IBMs line of AS/400 (now called iSeries) minicomputers. ...
OS/400 is an operating system used on IBMs line of AS/400 (now called iSeries) minicomputers. ...
Control Data Corporation, or CDC, was one of the pioneering supercomputer firms. ...
NOS may refer to: Network operating system, a kind of computer software Net outside sales Nokia OS, operating system software for Nokia mobile telephones Nitrous Oxide a gas used painkiller for surgeries and an automobile propellant. ...
The colon (:) is a punctuation mark, visually consisting of two equally sized dots centered on the same vertical line. ...
OpenVMS[1] (Open Virtual Memory System or just VMS) is the name of a high-end computer server operating system that runs on the VAX[2] and Alpha[3] family of computers developed by Digital Equipment Corporation of Maynard, Massachusetts (DIGITAL was then purchased by Compaq, and is now owned...
This article needs to be wikified. ...
Files-11, also known as on-disk structure, is the filesystem used by Hewlett-Packards OpenVMS operating system, and also (in a simpler form) by the older RSX-11. ...
Mainframe may refer to one of the following: Mainframe computer, large data processing systems Mainframe Entertainment, a Canadian computer animation and design company. ...
A CTR census machine, utilizing a punched card system. ...
For other senses of this word, see protocol. ...
HTTP (for HyperText Transfer Protocol) is the primary method used to convey information on the World Wide Web. ...
Simple Mail Transfer Protocol (SMTP) is the de facto standard for e-mail transmissions across the Internet. ...
FTP or File Transfer Protocol is used to transfer data from one computer to another over the Internet, or through a network. ...
Internet Relay Chat (IRC) is a form of real-time Internet chat or synchronous conferencing. ...
C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...
qmail is a mail transfer agent that runs on Unix. ...
A mail transfer agent or MTA (also called a mail transport agent, mail server, or a mail exchanger in the context of the Domain Name System) is a computer program or software agent that transfers electronic mail messages from one computer to another. ...
Unicode The Unicode standard addresses the problem by defining a large number of characters that conforming applications should recognize as line terminators: Unicode is an industry standard designed to allow text and symbols from all of the writing systems of the world to be consistently represented and manipulated by computers. ...
LF: Line Feed, U+000A CR: Carriage Return, U+000D CR+LF: CR followed by LF, U+000D followed by U+000A NEL: Next Line, U+0085 FF: Form Feed, U+000C LS: Line Separator, U+2028 PS: Paragraph Separator, U+2029 In computing, line feed (LF) is a control character indicating that one line should be fed out. ...
Originally, carriage return was the term for the key, lever, or mechanism on a typewriter that would cause the cylinder on which the paper was held (the carriage) to return to the left side of the paper after a line of text had been typed, and would often move it...
This may seem overly complicated compared to an approach such as converting all line terminators to a single character, for example LF. The simple approach breaks down, however, when trying to convert a text file from an encoding like EBCDIC to Unicode and back. When converting to Unicode, NEL would have to be replaced by LF, but when converting back it would be impossible to decide if a LF should be mapped to an EBCDIC LF or NEL. The approach taken in the Unicode standard allows this transformation to be information-preserving while still enabling applications to recognize all possible types of line terminators. EBCDIC (Extended Binary Coded Decimal Interchange Code) is an 8-bit character encoding (code page) used on IBM mainframe operating systems, like z/OS, OS/390, VM and VSE, as well as IBM minicomputer operating systems like OS/400 and i5/OS. It is also employed on various non-IBM...
History ASCII was developed simultaneously by the ISO and the ASA, the predecessor organization to ANSI. During the period of 1963–1968, the ISO draft standards supported the use of either CR+LF or LF alone as a newline, while the ASA drafts supported only CR+LF. The Multics operating system began development in 1964 and used LF alone as its newline. Unix followed the Multics practice, and later systems followed Unix. The International Organization for Standardization (ISO) is an international standard-setting body composed of representatives from national standards bodies. ...
The American National Standards Institute or ANSI (pronounced an-see) is a nonprofit organization that oversees the development of standards for products, services, processes and systems in the United States. ...
1963 (MCMLXIII) was a common year starting on Tuesday (the link is to a full 1963 calendar). ...
1968 (MCMLXVIII) was a leap year starting on Monday. ...
Multics (Multiplexed Information and Computing Service) was an extraordinarily influential early time-sharing operating system. ...
1964 (MCMLXIV) was a leap year starting on Wednesday (the link is to a full 1964 calendar). ...
Filiation of Unix and Unix-like systems Unix (officially trademarked as UNIX®) is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T employees at Bell Labs including Ken Thompson, Dennis Ritchie and Douglas McIlroy. ...
The sequence CR+LF was in common use on many early computer systems that had adapted teletype machines, typically an ASR33, as a console device, because this sequence was required to position those printers at the start of a new line. On these systems text was often routinely composed to be compatible with these printers, since the concept of device drivers hiding such hardware details from the application was not yet well developed; applications had to talk directly to the teletype machine and follow its conventions. The separation of the two functions concealed the fact that the print head could not return from the far right to the beginning of the next line in one-character time. That is why the sequence was always sent with the CR first. In fact, it was often necessary to send CR+LF+NUL (ending with the control character indicating "do nothing") or CR+CR+LF (sending CR twice) to be sure that the print head had stopped bouncing.[citation needed] Once these mechanical systems were replaced, the two-character sequence had no functional significance, but it has persisted in some systems anyway. A teleprinter (teletypewriter, teletype or TTY) is a now largely obsolete electro-mechanical typewriter which can be used to communicate typed messages from point to point through a simple electrical communications channel, often just a pair of wires. ...
Introduced about 1963, Teletype Corporations ASR33 was a very popular model of teleprinter. ...
Windows XP loading drivers during a Safe Mode bootup A device driver, or a software driver is a specific type of computer software, typically developed to allow interaction with hardware devices. ...
MS-DOS, built upon a CP/M clone called QDOS (which Microsoft purchased and renamed), adopted CP/M's CR+LF; CP/M's adoption of CR+LF is consistent with its original teletype oriented design[citation needed]. This convention was inherited by Microsoft's later Windows operating system. QDOS (Quick and Dirty Operating System) was the working title for 86-DOS, an operating system developed and marketed by Seattle Computer Products for its Intel 8086-based computer kit. ...
Microsoft is one of few companies engaging itself in the console wars Where they are up against sony, nintendo, and of course sharps new console which may cause a threat. ...
Microsoft Windows is the name of several families of proprietary software operating systems by Microsoft. ...
Newline in programming languages To facilitate creation of portable programs, programming languages provide some abstractions to deal with the different types of newline sequences used in different environments. In computer science, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed (e. ...
The C programming language provides the escape sequences 'n' (newline) and 'r' (carriage return). However, contrary to popular belief, these are in fact not required to be equivalent to the ASCII LF and CR control characters. The C standard only guarantees two things: C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...
To meet Wikipedias quality standards, this article or section may require cleanup. ...
- Each of these escape sequences maps to a unique implementation-defined number that can be stored in a single char value.
- When writing a file in text mode, 'n' is transparently translated to the native newline sequence used by the system, which may be longer than one character. (Note that a C implementation is allowed not to store newline characters in files. For example, the lines of a text file could be stored as rows of a SQL table or as fixed-length records.) When reading in text mode, the native newline sequence is translated back to 'n'. In binary mode, the second mode of I/O supported by the C library, no translation is performed, and the internal representation of any escape sequence is output directly.
On Unix platforms, where C originated, the native newline sequence is ASCII LF (0x0A), so 'n' was simply defined to be that value. With the internal and external representation being identical, the translation performed in text mode effectively turns into a no-op, making text mode and binary mode behave the same. This has caused many programmers who developed their software on Unix systems to simply ignore the distinction completely, resulting in code that is not portable to different platforms. SQL (commonly expanded to Structured Query Language â see History for the terms derivation) is the most popular computer language used to create, retrieve, update and delete (see also: CRUD) data from relational database management systems. ...
In computing, input/output, or I/O, is the collection of interfaces that different functional units (sub-systems) of an information processing system use to communicate with each other, or the signals (information) sent through those interfaces. ...
NOP or NOOP (short for No OPeration) is an assembly language instruction, sequence of programming language statements, or computer protocol command that does nothing at all. ...
Another common problem is the use of 'n' when communicating using an Internet protocol that mandates the use of ASCII CR+LF for ending lines. Writing 'n' to a text mode stream works correctly on Windows systems, but produces only LF on Unix, and something completely different on more exotic systems. Using "rn" in binary mode is slightly better, as it works on many ASCII-compatible systems, but still fails miserably in the general case. One approach is to use binary mode and specify the numeric values of the control sequence directly, "
". C++ provides the same interpretation of 'n' as C, and also provides std::endl, which represents the underlying system's representation of a newline and flushes the stream after emitting the newline. C++ (pronounced see plus plus, IPA: ) is a general-purpose, high-level programming language with low-level facilities. ...
Java also provides 'n' and 'r' escape sequences. In contrast to C, these are guaranteed to represent the values 0x0A and 0x0D, respectively. The Java I/O libraries do not transparently translate these into platform dependent newline sequences on input or output. Instead, they provide functions for writing a full line that automatically add the native newline sequence, and functions for reading lines that accept any of CR, LF, or CR+LF as a line terminator (see BufferedReader.readLine()). Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. ...
Common problems The different newline conventions often cause text files that have been transferred between systems of different types to be displayed incorrectly. For example, files originating on Unix or Apple Macintosh systems may appear as a single long line on a Windows system. Conversely, when viewing a file from a Windows computer on a Unix system, the extra CR may be displayed as ^M at the end of each line or as a second line break. Filiation of Unix and Unix-like systems Unix (officially trademarked as UNIX®) is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T employees at Bell Labs including Ken Thompson, Dennis Ritchie and Douglas McIlroy. ...
The first Macintosh computer, introduced in 1984, upgraded to a 512K Fat Mac. The Macintosh or Mac, is a line of personal computers designed, developed, manufactured, and marketed by Apple Computer. ...
Microsoft Windows is the name of several families of proprietary software operating systems by Microsoft. ...
The problem can be hard to spot if some programs handle the foreign newlines properly while others don't. For example, a compiler may fail with obscure syntax errors even though the source file looks correct when displayed on the console or in an editor. Modern text editors generally recognize all flavours of CR / LF newlines and allow the user to convert between the different standards. Web browsers are usually also capable of displaying text files of different types. This article is about the computing term. ...
This article or section does not adequately cite its references or sources. ...
Notepad is the standard text editor for Microsoft Windows A text editor is a piece of computer software for editing plain text. ...
An example of a web browser (Mozilla Firefox), displaying the English Wikipedia main page. ...
The File Transfer Protocol can automatically convert newlines in files being transferred between systems with different newline representations when the transfer is done in ASCII mode. However, transferring binary files in this mode usually has disastrous results: Any occurrence of the newline byte sequence—which does not have line terminator semantics in this context, but is just a normal sequence of bytes—will be translated to whatever newline representation the other system uses, effectively corrupting the file. FTP clients often employ some heuristics (for example inspection of filename extensions) to automatically select either binary or ASCII mode, but in the end it is up to the user to make sure his files are transferred in the correct mode. If there is any doubt as to the correct mode, binary mode should be used, as then no files will be altered by FTP, though they may display incorrectly. FTP or File Transfer Protocol is used to transfer data from one computer to another over the Internet, or through a network. ...
An operating system (OS) is a set of computer programs that manage the hardware and software resources of a computer. ...
In computer science, besides the common use as rule of thumb (see heuristic), the term heuristic has two well-defined technical meanings. ...
A filename extension is a suffix to the name of a computer file applied to show its format. ...
Conversion utilities Generally, using a text editor is the simplest and most convenient way of converting a text file between different newline formats; most modern editors can read and write files using at least the different ASCII CR/LF conventions. Unfortunately, the standard Windows editor Notepad is not one of them, though Wordpad is. Microsoft Windows is the name of several families of proprietary software operating systems by Microsoft. ...
For the item of stationery, see notebook. ...
WordPad is a simple word processor that is included with almost all versions of Microsoft Windows from Windows 95 upwards. ...
On Windows systems without a better editor, the old MS-DOS editor EDIT that still ships with modern Windows versions can be used to convert a Unix text file to DOS/Windows newlines. A simple way of doing this is by creating a shortcut to EDIT on the desktop (context menu / New / Shortcut / "edit" / Next / Finish), dragging the text file in question onto it, and then saving the file again (File / Save). Editors are often unsuitable for converting larger files. For larger files (on Windows NT/2000/XP) you can use the following command: TYPE unix_file | FIND "" /V > dos_file On many Unix systems, the dos2unix (sometimes named fromdos) and unix2dos (sometimes named todos) utilities can be used to translate between ASCII CR+LF (DOS/Windows) and LF (Unix) newlines. Different versions of these commands vary slightly in their syntax. However, the tr command is available on virtually every Unix-like system and can be used to perform arbitrary replacement operations on single characters. A DOS/Windows text file which contains no CR within its lines can be converted to Unix format by simply removing all ASCII CR characters with Filiation of Unix and Unix-like systems Unix (officially trademarked as UNIX®) is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T employees at Bell Labs including Ken Thompson, Dennis Ritchie and Douglas McIlroy. ...
The title given to this article is incorrect due to technical limitations. ...
Diagram of the relationships between several Unix-like systems A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification. ...
tr -d 'r' < inputfile > outputfile or, if the text has only CR's, by converting CRs to LFs with tr 'r' 'n' < inputfile > outputfile Those same tasks can be performed in a much cleaner way with sed, or in Perl if the platform has a Perl interpreter: The correct title of this article is . ...
Perl is a dynamic programming language created by Larry Wall and first released in 1987. ...
sed -e 's/$/r/' inputfile > outputfile # UNIX to DOS (adding CRs) sed -e 's/r$//' inputfile > outputfile # DOS to UNIX (removing CRs) perl -p -e 's/(rn|n|r)/rn/g' inputfile > outputfile # Convert to DOS perl -p -e 's/(rn|n|r)/n/g' inputfile > outputfile # Convert to UNIX perl -p -e 's/(rn|n|r)/r/g' inputfile > outputfile # Convert to old Mac On Unix systems the file utility provides a convenient way of identifying what type of line breaks a text file contains. Filiation of Unix and Unix-like systems Unix (officially trademarked as UNIX®) is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T employees at Bell Labs including Ken Thompson, Dennis Ritchie and Douglas McIlroy. ...
file is a program originated in Unix that runs under the shell (command-line) to determine the file type heuristically instead of other simpler ways to classify it, like with file extensions, MIMEs, etc. ...
See also The C0 and C1 control code sets define control codes for use in text. ...
External links |