为什么回车 return 出现在换行之前

Why does carriage return come before new line

有很多问题询问 return 和换行符在 Windows 上的正确顺序是什么(它是 \r\n),但我没有找到任何真正的解释至于为什么会这样。

\n是换行符,\r是回车return。因此,如果您首先有 \r,return 将光标移动到当前行的开头 - 然后是 \n,那么逻辑上不会插入 \n在当前行的开头,只是将当前行向下移动一个而不是在之后创建一行?

我的意思是我明白,当简单地将这些写入文件时它并不重要,但是当 parsing/reading 并输出文本时,这对我来说似乎是倒退的。

该订单是对打字机时代的致敬。

Early mechanical printers were too slow to return the carriage in the time it took to process one character. Therefore the time spent sending the line feed was not wasted (often several more characters had to be sent to ensure the carriage return had happened before sending a printing character). This is why the carriage return was always sent first.

Link: http://en.wikipedia.org/wiki/Carriage_return