{"id":20993,"date":"2014-02-28T11:42:31","date_gmt":"2014-02-28T09:42:31","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=20993"},"modified":"2014-02-28T11:42:31","modified_gmt":"2014-02-28T09:42:31","slug":"why-are-there-different-representations-for-newlines-in-windows-linux-and-mac","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2014\/02\/28\/why-are-there-different-representations-for-newlines-in-windows-linux-and-mac\/","title":{"rendered":"Why are there different representations for newlines in Windows, Linux, and Mac?"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><a href=\"http:\/\/www.quora.com\/Operating-Systems\/Why-are-there-different-representations-for-newlines-in-Windows-Linux-and-Mac\">Why are there different representations for newlines in Windows, Linux, and Mac?<\/a><\/p>\n<blockquote><p>This is a good question albeit one with a boring answer. Different systems evolved different encodings for newlines in the same way they evolved different behavior for myriad other things: Each system had to standardize on something and interoperability in the days before email let alone the Internet was unimportant.<\/p>\n<p>There are several ways to represent newlines. ASCII-based systems use some combination of\u00a0<i>carriage return<\/i>\u00a0and\u00a0<i>line feed<\/i>. These derive from typewriters: A carriage return (CR) resets the typewriter carriage&#8217;s horizontal position to the far left and a line feed (LF) advances the paper one vertical line. For a typewriter, you need both, so some systems (DOS, Windows, Palm OS) adopted CR+LF as representation of a newline. Other systems, such as Unix, noted a computer didn&#8217;t have a carriage to return so a sole line feed was sufficient. Still others, such as Mac OS prior to OS X, adopted only a carriage return\u2014arguably, this choice doesn&#8217;t make any sense, as a bare carriage return would swing the typewriter carriage back to the left but not advance the page. Still other systems used LF+CR, inverting the ASCII characters used in Windows.<\/p>\n<p>Systems not based on ASCII, of course, did their own thing. IBM mainframes built around EBCDIC, for example, used a special\u00a0<i>newline<\/i>\u00a0character (NL). Perhaps oddest of all, VMS utilized a record-based filesystem where newlines were first-class citizens to the operating system. Each record was implicitly its own line and thus there were no explicit newline representation!<\/p>\n<p>But none of this mattered, because these systems never had to interoperate with each other\u2014or, if they did, they had to make so many other conversions that newline representation was the least of their worries.<\/p>\n<p>Today, most Internet protocols recommend CR+LF but dictate compatibility with LF (CR and LF+CR are left out in the cold). Given the centrality of the Internet, the ubiquity of Unix, which heralds LF, the primacy of C and descendant languages, which (somewhat) map their newline to LF, and the fact we really only need one character to represent a newline, LF seems the clear standard going forward.<\/p><\/blockquote>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Why are there different representations for newlines in Windows, Linux, and Mac? This is a good question albeit one with a boring answer. Different systems evolved different encodings for newlines in the same way they evolved different behavior for myriad other things: Each system had to standardize on something and interoperability in the days before &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2014\/02\/28\/why-are-there-different-representations-for-newlines-in-windows-linux-and-mac\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Why are there different representations for newlines in Windows, Linux, and Mac?<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"link","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,6,18,62,1334],"tags":[286],"keyring_services":[],"class_list":["post-20993","post","type-post","status-publish","format-link","hentry","category-general","category-linux","category-programming","category-technology","category-web-work","tag-history","post_format-post-format-link"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":22936,"url":"https:\/\/mamchenkov.net\/wordpress\/2014\/11\/20\/nightrain-php-packager-for-native-applications-on-windows-linux-and-mac-os\/","url_meta":{"origin":20993,"position":0},"title":"nightrain &#8211; PHP packager for native applications on Windows, Linux, and Mac OS","author":"Leonid Mamchenkov","date":"November 20, 2014","format":"link","excerpt":"PHP Nightrain is a packager written in Python for the PHP Programming Language. Using this tool you can convert your PHP\/HTML\/CSS\/Javascript application to a Native Desktop Application. Currently, PHP Nightrain supports the Windows, Mac (OS X) and the Linux operating systems. \u00a0This is basically PhoneGap for desktop.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":15470,"url":"https:\/\/mamchenkov.net\/wordpress\/2011\/09\/06\/the-purpose-of-an-operating-system\/","url_meta":{"origin":20993,"position":1},"title":"The purpose of an operating system","author":"Leonid Mamchenkov","date":"September 6, 2011","format":false,"excerpt":"I came across a good reminder of the operating system's purpose in this Slashdot comment: The point of an OS is to make the software independent of the underlying hardware. Windows lost that independence a LONG while ago (Windows NT \/ 95). Linux still has it because of the underlying\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":16671,"url":"https:\/\/mamchenkov.net\/wordpress\/2012\/09\/04\/major-linux-problems-or-why-linux-is-not-yet-ready-for-the-desktop-2012-edition\/","url_meta":{"origin":20993,"position":2},"title":"Major Linux Problems or Why Linux is not (yet) Ready for the Desktop, 2012 edition","author":"Leonid Mamchenkov","date":"September 4, 2012","format":"link","excerpt":"Major Linux Problems or Why Linux is not (yet) Ready for the Desktop, 2012 edition Every operating system has its problems. \u00a0Some things work better than in others, some do worse. \u00a0Here is an interesting (and very up-to-date) overview of the problems in the Linux space. \u00a0The good thing about\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28105,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/10\/16\/ioquake3-free-software-fps-game-engine-based-on-quake-3-for-windows-linux-and-macos\/","url_meta":{"origin":20993,"position":3},"title":"ioquake3 &#8211; Free Software FPS Game Engine Based on Quake 3 for Windows, Linux, and macOS","author":"Leonid Mamchenkov","date":"October 16, 2017","format":false,"excerpt":"ioquake3 is the modern, cross-platform distribution of the Quake 3 engine with a few extra bits and pieces.\u00a0 As per the GitHub repository: The intent of this project is to provide a baseline Quake 3 which may be used for further development and baseq3 fun. Some of the major features\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9372,"url":"https:\/\/mamchenkov.net\/wordpress\/2005\/08\/25\/quake-iii-arena-source-code-gpled\/","url_meta":{"origin":20993,"position":4},"title":"Quake III Arena source code GPLed","author":"Leonid Mamchenkov","date":"August 25, 2005","format":false,"excerpt":"id Software has released the source code for its Quake III Arena for the public under the GPL. That is even before Quake 4 has been released! If you're interested, you can download the source code here. Now game writers all over the world can unite and produce some really\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10868,"url":"https:\/\/mamchenkov.net\/wordpress\/2007\/10\/23\/something-is-wrong-with-windows-vista\/","url_meta":{"origin":20993,"position":5},"title":"Something is wrong with Windows Vista","author":"Leonid Mamchenkov","date":"October 23, 2007","format":false,"excerpt":"Disclaimer: I never used Windows Vista. It's been a while since I used Microsoft Windows. I am a proud Linux user. For a few years now. I am very biased. I am not well informed on this subject. Now, with the above disclaimer, it might seem that I don't have\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/20993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=20993"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/20993\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=20993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=20993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=20993"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=20993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}