Historical reason behind different line ending at different platforms

后端 未结 3 857
别跟我提以往
别跟我提以往 2020-11-30 08:35

Why did DOS/Windows and Mac decide to use \\r\\n and \\r for line ending instead of \\n? Was it just a result of trying to be \"different\" from Unix?

And now that M

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 09:13

    DOS inherited CR-LF line endings (what you're calling \r\n, just making the ascii characters explicit) from CP/M. CP/M inherited it from the various DEC operating systems which influenced CP/M designer Gary Kildall.

    CR-LF was used so that the teletype machines would return the print head to the left margin (CR = carriage return), and then move to the next line (LF = line feed).

    The Unix guys handled that in the device driver, and when necessary translated LF to CR-LF on output to devices that needed it.

    And as you guessed, Mac OS X now uses LF.

提交回复
热议问题