e01.org

Newline

A newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. A newline is used to signify the end of a line of text and the start of a new one. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

A newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. A newline is used to signify the end of a line of text and the start of a new one. String eol = System.lineSeparator(); String lineColor = "Color: Red" + eol; Python has a "universal newline support" feature enabled by default, which translates all three commonly found line ending conventions ( \n , \r , \r\n ) into Python's standard \n convention when opening a file for reading, when importing modules, and when executing a file. This feature can be controlled using the newline argument in the open() function when opening the file. Some languages have created special variables, constants, and subroutines to facilitate newlines during program execution. In some languages such as PHP and Perl, double quotes are required to perform escape substitution for all escape sequences, including \n and \r . In PHP, to avoid portability problems, newline sequences should be issued using the PHP_EOL constant. Example in C#: string eol = Environment.NewLine; string lineColor = "Color: Red" + eol; string eol2 = "\n"; string lineColor2 = "Color: Blue" + eol2; :set fileformat=dos :wq Editors can be unsuitable for converting larger files or bulk conversion of many files. For larger files (on Windows NT) the following command is often used: D:\>TYPE unix_file | FIND /V "" > dos_file Special purpose programs to convert files between different newline conventions include and , and , and , and . The 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 can be converted to Unix format by simply removing all ASCII characters with $ tr -d '\r' < inputfile > outputfile or, if the text has only newlines, by converting all newlines to with $ tr '\r' '\n' < inputfile > outputfile The same tasks are sometimes performed with awk, sed, or in Perl if the platform has a Perl interpreter: $ awk '{sub("$","\r\n"); printf("%s",$0);}' inputfile > outputfile # UNIX to DOS (adding CRs on Linux and BSD based OS that haven't GNU extensions) $ awk '{gsub("\r",""); print;}' inputfile > outputfile # DOS to UNIX (removing CRs on Linux and BSD based OS that haven't GNU extensions) $ sed -e 's/$/\r/' inputfile > outputfile # UNIX to DOS (adding CRs on Linux based OS that use GNU extensions) $ sed -e 's/\r$//' inputfile > outputfile # DOS to UNIX (removing CRs on Linux based OS that use GNU extensions) $ perl -pe 's/\r?\n|\r/\r\n/g' inputfile > outputfile # Convert to DOS $ perl -pe 's/\r?\n|\r/\n/g' inputfile > outputfile # Convert to UNIX $ perl -pe 's/\r?\n|\r/\r/g' inputfile > outputfile # Convert to old Mac The command can identify the type of line endings: $ file myfile.txt myfile.txt: ASCII English text, with CRLF line terminators The Unix egrep (extended grep) command can be used to print filenames of Unix or DOS files (assuming Unix and DOS-style files only, no classic Mac OS-style files): $ egrep -L '\r\n' myfile.txt # show UNIX style file (LF terminated) $ egrep -l '\r\n' myfile.txt # show DOS style file (CRLF terminated) Other tools permit the user to visualise the EOL characters: $ od -a myfile.txt $ cat -e myfile.txt $ cat -v myfile.txt $ hexdump -c myfile.txt

References

  1. What is a Newline? . www.computerhope.com . retrieved 2021-05-10 · 1620601200.0
  2. ECMAScript 2019 Language Specification . ECMA International . June 2019. · 1790550000.0
  3. Subsume JSON (a.k.a. JSON ⊂ ECMAScript) . GitHub . 22 May 2018. · 1790550000.0
  4. 5.4. Line Break Characters . YAML Ain't Markup Language revision 1.2.2 . 1 October 2021. · 1790550000.0
  5. HyperText Mark-up Language . info.cern.ch . retrieved 15 August 2025 · 1790550000.0
  6. <p>: The Paragraph element - HTML . MDN . 13 August 2025. · 1790550000.0
  7. <br>: The Line Break element - HTML . MDN . retrieved 15 August 2025 · 1790550000.0
  8. binmode . Perl documentation . · 1790550000.0
  9. PHP: Strings - Manual . PHP Manual . · 1790550000.0
  10. 2. Lexical analysis . The Python Language Reference . · 1790550000.0
  11. Jansen, Jack. PEP 278 – Universal Newline Support . Python Enhancement Proposals . 14 January 2002. · 1790550000.0
  12. Qualline, Steve. Vi Improved - Vim . Sams Publishing . 2001. · 1790550000.0
  13. What's new in Python 2.3 . Python 2.3 . · 1790550000.0
  14. PHP: Predefined Constants - Manual . PHP Manual . · 1790550000.0
  15. Bernstein, D. J. Bare LFs in SMTP . · 1790550000.0
  16. Resnick, Pete. Internet Message Format . April 2001. · 1790550000.0
  17. Longin, Timo. SMTP Smuggling - Spoofing E-Mails Worldwide . SEC Consult . · 1790550000.0
  18. Zeil, Steven. File Transfer . Old Dominion University . · 1790550000.0
  19. Sapp, Craig Stuart. ASCII text converstion between UNIX, Macintosh, MS-DOS . Center for Computer Researc . · 1790550000.0
  20. pubs.opengroup.org The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024 . The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024 . · 1790550000.0
  21. stackoverflow.com The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024 . The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024 . · 1790550000.0
  22. C1 Controls and Latin-1 Supplement . unicode.org . retrieved 13 February 2016 · 1790550000.0
  23. Windows Notepad finally understands everyone else's end of line characters . · 1790550000.0
  24. Cite journal |last=Spears |first=Richard A. |last2=Steele |first2=Guy L. |date=1986 |editor-last=Woods |editor-first=Donald R. |editor2-last=Finkel |editor2-first=Raphael A. |editor3-last=Crispin |e . · 1790550000.0
  25. Introducing extended line endings support in Notepad . · 1790550000.0
  26. Kahn-Greene, Will Guaraldi. ASCII chart . bluesock.org . · 1790550000.0
  27. Networking the QL and ZX Spectrum, part 1 . · 1790550000.0
  28. Bray, Andrew C. The Advanced User Guide for the BBC Microcomputer . 1983. · 1790550000.0
  29. Character Output . RISC OS 3 Programmers' Reference Manual . 3 Novembe. · 1790550000.0
  30. Heninger, Andy. UAX #14: Unicode Line Breaking Algorithm . The Unicode Consortium . 20 September 2013. · 1790550000.0
source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Newline". 1790638700. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1377351180

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·