<p>在网络虚拟终端会话中,<code>'\r'</code>字符是回车,回车换行对都是换行所必需的。</p>
<hr/>
<p>从<a href="https://tools.ietf.org/html/rfc854">old telnet specification (RFC 854)</a>(第11页):</p>
<blockquote>
<p>The sequence "CR LF", as defined, will cause the NVT to be
positioned at the left margin of the next print line (as would,
for example, the sequence "LF CR").</p>
</blockquote>
<p>但是,在<a href="https://tools.ietf.org/html/rfc5198">latest specification (RFC5198)</a>(第13页)中:</p>
<blockquote>
<ol>
<li><p>...</p></li>
<li><p>In Net-ASCII, CR MUST NOT appear except when immediately followed
by either NUL or LF, with the latter (CR LF) designating the "new
line" function. Today and as specified above, CR should
generally appear only when followed by LF. Because page layout
is better done in other ways, because NUL has a special
interpretation in some programming languages, and to avoid other
types of confusion, CR NUL should preferably be avoided as
specified above.</p></li>
<li><p>LF CR SHOULD NOT appear except as a side-effect of multiple CR LF
sequences (e.g., CR LF CR LF).</p></li>
</ol>
</blockquote>
<p>因此,Telnet中的newline应该始终是<code>'\r\n'</code>,但大多数实现要么没有更新,要么保留旧的<code>'\n\r'</code>以实现向后兼容性。</p>