Unix、Mac、DOS/Windows 选择不同换行表示的理由?

发布于 2024-08-17 22:53:32 字数 187 浏览 4 评论 0原文

有谁知道不同平台各自选择不同但在某种程度上相似的新线路表示的原始原理或故事?最初必须做出一些设计决策。 (我不相信这都是随机选择...)

  • Unix/Mac OS X: LF (\n)
  • Mac OS 9 及之前: CR (\r)
  • DOS/Windows: CRLF (\r\n)

Does anyone know the original rationale, or story, of the different platforms each choosing a different, yet similar to some degree, new line representation? There must be some design decisions made originally. (I don't believe this is all random choice ...)

  • Unix/Mac OS X: LF (\n)
  • Mac OS 9 and before: CR (\r)
  • DOS/Windows: CRLF (\r\n)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蝶…霜飞 2024-08-24 22:53:32

上发表了关于这个主题的文章

Jeff Atwood 在 “The Great Newline Schism”维基百科 涵盖换行符的历史

简而言之,CR+LF 是对电动打字机时代的参考,当时您首先使用回车符将光标向左移动,然后使用换行符向下移动一行。您有时会只使用其中之一来书写特殊字符,例如下划线或删除线。

CRLF

计算机采用此命名法,因为它对于与 teletype 交互非常有用机器。这就是 MS-DOS 和随后的 Windows 使用 CRLF 的原因。

LF

显然,Multics 和随后的 Unix 从 1963 年汲取了灵感ISO 草案标准的 -64 草案表明 CRLF 或 LF 可以代表换行符,并使用单个 LF 字符。

CR

我对苹果采用CR的历史仍然有点困惑。我正在调查它...
到目前为止,我最好的猜测是,这是由于苹果早期区分了 enter返回。在早期,回车键映射为回车,回车键映射为换行,而不是像 Windows 世界那样使用一个具有双重功能的“回车”键。对于经常使用回车符进行特殊格式设置的打字机用户来说,将两者分开可能是有意义的,事实上,苹果确实使用回车键进行特殊格式设置选项。

我不太确定的是,当他们放弃这个时,他们决定只使用 CR,但我的猜测是它可以追溯到早期决定使用 CR 作为返回键......但我可能是错的。

Jeff Atwood posted on this very topic in "The Great Newline Schism"

Wikipedia covers the history of newline.

In short, CR+LF is a reference to the electric typewriter days when you would first use a carriage return to move the cursor to the left and a line feed to move down a line. You would occasionally just use one or the other for writing special characters such as underline or strike-through.

CRLF

Computers adopted this nomenclature as it was useful for interacting with teletype machines. This is why MS-DOS and subsequently Windows use CRLF.

LF

Apparently, Multics and subsequently Unix took their cue from the 1963-64 draft of the ISO draft standards which indicated that either CRLF or LF could represent newline, and went with the single LF character.

CR

I'm still a bit puzzled about the history of apple adopting CR. I'm looking into it...
So far, my best guess is that this is due to apple's early distinction between the enter and return keys. In the early days, the return key mapped to a carriage return and the enter key to a line feed, rather than having a single "enter" key that does double duty, like in the Windows world. To typewriter users, who would routinely use the carriage return for special formatting, this may have made sense to separate the two and apple did, in fact, use the return key for special formatting options.

Where I'm not so sure is how, when they abandoned this, they settled on just using CR, but my guess is it dates to this early decision to use CR for the return key...but I may be wrong.

长伴 2024-08-24 22:53:32

嗯,\r\n 是回车然后换行,这与打字机上用于从左列开始新行的按键序列相同。

Well, \r\n is Carriage Return then Linefeed, which is the same sequence of keys used to start a new line from the left column on a typewriter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文