76 个字符成为电子邮件 MIME 部分长度限制 (RFC 2045) 的原因是什么?

发布于 2024-10-17 11:38:08 字数 75 浏览 10 评论 0原文

RFC 2045 将编码数据的最大行长度定义为 76。但是,我找不到任何解释为什么它是 76。这个数字完全是任意的,还是背后有一些推理?

RFC 2045 defines the maxmimum line length for encoded data as 76. However, I cannot find any explanation as to why it is 76. Is this number entirely arbitrary, or is there some reasoning behind it?

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

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

发布评论

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

评论(4

梦初启 2024-10-24 11:38:08

RFC2822 是电子邮件的旧标准。
在RFC2822的2.1.1节中,可以找到原因如下:
它还会影响 MIME。

该标准对数量有两个限制
一行中的字符。每行字符不得超过
998 个字符,并且不应超过 78 个字符,不包括
CRLF。

998 个字符的限制是由于许多方面的限制
发送、接收或存储互联网消息的实现
格式化无法处理超过 998 个字符的消息
在一条线上。接收实现可以很好地处理
一行中任意数量的字符以保证稳健性
清酒。然而,有如此多的实现(在
符合 [RFC2821] 的运输要求)不
接受包含超过 1000 个字符的消息,包括
每行 CR 和 LF,对于实现来说重要的是不要
创建这样的消息。

比较保守的78个字符建议是为了适应
显示这些内容的用户界面的许多实现
可能会截断或灾难性地换行的消息
每行超过 78 个字符,尽管这样
实现不符合此意图
规范(以及 [RFC2821] 的规范,如果它们确实导致
信息丢失)。再次强调,即使有这个限制
消息,它依赖于显示消息的实现
处理一行中任意数量的字符
(当然至少达到 998 个字符的限制)为了
鲁棒性。

RFC2822 is legacy standard of EMail.
In section 2.1.1 of RFC2822, you can find reason as below:
It also affects MIME.

There are two limits that this standard places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.

The 998 character limit is due to limitations in many
implementations which send, receive, or store Internet Message
Format messages that simply cannot handle more than 998 characters
on a line. Receiving implementations would do well to handle an
arbitrarily large number of characters in a line for robustness
sake. However, there are so many implementations which (in
compliance with the transport requirements of [RFC2821]) do not
accept messages containing more than 1000 character including the
CR and LF per line, it is important for implementations not to
create such messages.

The more conservative 78 character recommendation is to accommodate
the many implementations of user interfaces that display these
messages which may truncate, or disastrously wrap, the display of
more than 78 characters per line, in spite of the fact that such
implementations are non-conformant to the intent of this
specification (and that of [RFC2821] if they actually cause
information to be lost). Again, even though this limitation is put on
messages, it is encumbant upon implementations which display messages
to handle an arbitrarily large number of characters in a line
(certainly at least up to the 998 character limit) for the sake of
robustness.

做个少女永远怀春 2024-10-24 11:38:08

实际上,原始 RFC 822 定义了 72 个字符的限制,罪魁祸首是 电传打字机,它是早期计算机的标准输出设备。

您还可以“感谢”电传打字机,因为电子邮件(和 Windows)中的行终止符为 2 个字符,即 CR(回车)和 LF(换行)。

必须在每行末尾传输此序列,以便电传打字机将插入符号移动到位置 0 并将纸张向前推进一个刻度。

当 RFC 2822 废弃原始版本时,没有人使用电传打字机来呈现电子邮件,因此它被放宽了一点,以便适应默认的 TTY 监控设备。

Actually the original RFC 822 defines a limit at 72 characters and the culprit is a teletype, which was a standard output device with the early computers.

You can also "thank" teletype devices for the line terminator in emails (and Windows) being 2 characters, which are CR (Carriage Return) and LF (Line Feed).

It was essential to transmit this sequence at the end of each line in order for a teletype to move a caret to position 0 and advance paper one tick up.

By the time RFC 2822 obsoleted the original, nobody was using teletypes to render emails, so it was relaxed a bit in order to fit into a default TTY monitor device.

萌酱 2024-10-24 11:38:08

最大行长度 80(包括终止回车和换行)源自老式打孔卡,其中最多包含 80 列孔。
为什么是80?因为在任何书中,一行的长度很少超过 80 个字符(包括空格)。
它意味着最大行长度为 80,包括终止回车(将电传打字机或打字机的托架移动到最左边的位置)和换行(将纸张前进一行)。
由于 Base64 是 4 个字符的倍数,因此我们最终得到的最大值为 76,不包括 CR+LF。
另一个例子是 TLE(双线元素集),它描述了卫星的轨道。它只适合两张打孔卡。
由于CR(水平移动到最左边,保持垂直位置)和LF(垂直移动到下一行,保持水平位置不变)是两个完全独立的东西,所以我们仍然拥有它们。下一行应该从最左边的位置开始,不是吗?
对于粗体打印,一行被打印两次,它们之间只有一个 CR,即不推进纸张。因此标准顺序是先CR 再LF。
然而,老式的机械打字机通常先输入 LF,然后再输入 CR。

The maximum line length of 80 including the terminating carriage return and line feed originates from the good old punch cards which contained up to 80 colums of holes.
Why 80? Because in any book, a line is rarely longer than 80 characters including spaces.
It implied a maximum line length of 80 including the terminating Carriage Return (which moved the carriage of the teletype or typing machine to the leftmost position) and Line Feed (which advanced the paper by one line).
Since Base64 is in multiples of 4 characters, we end up with a maximum of 76, not counting CR+LF.
Another example is the TLE (Two-Line Element set) which describes a satellite's orbit. It fits on just two punch cards.
Since CR (horizontal movement to the leftmost, maintaining the vertical position) and LF (vertical movement to next line, keeping the horizontal position as is) are two fully independent things, we still have both of them. The next line should start at the leftmost position, shouldn't it?
For printing in bold, a line was printed twice with only a CR between them, i.e. without advancing the paper. Therefore the standard sequence is CR first and then LF.
However, the good old mechanical typing machine usually did the LF first and then the CR.

烙印 2024-10-24 11:38:08

与用户界面有关的部分

http://en.wikipedia.org/wiki/Text_mode#PC_common_text_modes< /a>

基本上,80 个字符(通常是 25 或 30 行)是最常见的显示标准。 78 提供了一个合理的标准,因为这允许使用一些小装饰(边框)。

The bit to do with user interfaces

http://en.wikipedia.org/wiki/Text_mode#PC_common_text_modes

Basically, 80 characters across (and usually 25 or 30 lines) was the most common standard for displays. 78 provides a sane standard as this allows for some small decorations to be used (borders).

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