问题描述
为什么DOS/Windows和Mac决定使用\ r \ n和\ r而不是\ n来结束行?这仅仅是试图与Unix有所不同"的结果吗?
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?
现在Mac OS X是Unix(类似),Apple是否从\ r切换到\ n?
And now that Mac OS X is Unix (-like), did Apple switch to \n from \r?
推荐答案
DOS从CP/M继承了CR-LF行尾(您称呼\ r \ n,只是使ascii字符清晰可见). CP/M是从影响CP/M设计师Gary Kildall的各种DEC操作系统继承过来的.
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,以便电传打字机将打印头返回到左边距(CR =回车),然后移至下一行(LF =换行).
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).
Unix家伙在设备驱动程序中进行了处理,并在需要时将LF转换为CR-LF,输出到需要它的设备上.
The Unix guys handled that in the device driver, and when necessary translated LF to CR-LF on output to devices that needed it.
而且您猜到了,Mac OS X现在使用LF.
And as you guessed, Mac OS X now uses LF.
这篇关于在不同平台结束的不同行背后的历史原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!