以下控制字符的含义:

回车 换行 换页


当前回答

“\n”是换行字符。这意味着结束当前行,并为正在阅读它的任何人转到新的行。

其他回答

Carriage return and line feed are also references to typewriters, in that the with a small push on the handle on the left side of the carriage (the place where the paper goes), the paper would rotate a small amount around the cylinder, advancing the document one line. If you had finished typing one line, and wanted to continue on to the next, you pushed harder, both advancing a line and sliding the carriage all the way to the right, then resuming typing left to right again as the carriage traveled with each keystroke. Needless to say, word-wrap was the default setting for all word processing of the era. P:D

“\n”是换行字符。这意味着结束当前行,并为正在阅读它的任何人转到新的行。

简而言之:

回车符(\r或0xD):从同一行开始控制。 换行(\n或0xA):控制从下一行开始。 表单提要(\f或0xC):控制从下一页开始。


更多的细节和更多的控制字符可以在下面的页面找到:控制字符

Consider an IBM 1403 impact printer. CR moved the print head to the start of the line, but did NOT advance the paper. This allowed for "overprinting", placing multiple lines of output on one line. Things like underlining were achieved this way, as was BOLD print. LF advanced the paper one line. If there was no CR, the next line would print as a staggered-step because LF didn't move the print head. FF advanced the paper to the next page. It typically also moved the print head to the start of the first line on the new page, but you might need CR for that. To be sure, most programmers coded CRFF instead of CRLF at the end of the last line on a page because an extra CR created by FF wouldn't matter.

回车是指返回到当前行的开头,不向下移动。这个名字来源于打印机的支架,因为在这个名字被创造出来的时候显示器还很少见。这通常转义为“\r”,缩写为CR, ASCII值为13或0xD。

换行意味着向下推进到下一行;然而,它已被重新命名。作为“换行符”使用,它终止行(通常与分隔行混淆)。这通常转义为“\n”,缩写为LF或NL, ASCII值为10或0xA。CRLF(而不是CRNL)用于对“\r\n”。

表单提要意味着向下推进到下一个“页面”。它通常用作页面分隔符,但现在也用作部分分隔符。文本编辑器可以在“插入分页符”时使用此字符。它通常转义为“\f”,缩写为FF, ASCII值为12或0xC。


作为控制字符,它们可以有不同的解释方式。

最重要的解释是这些字符如何划线。在Unix(包括OS X)上以NL结尾,在Windows上以CRLF结尾,在旧的mac上以CR结尾。请注意,对于完全相同的字符,从LF到NL的含义的转换给出了Windows和Unix之间的差异,这也是为什么许多Windows程序使用CRLF来分隔而不是终止行。许多文本编辑器可以读取这三种格式中的任何一种格式的文件并在它们之间进行转换,但并非所有实用程序都可以。

表单提要不太常用。作为页面分隔符,它只能出现在行之间或文件的开始或结束处。