以下控制字符的含义:
回车 换行 换页
以下控制字符的含义:
回车 换行 换页
当前回答
作为补充,
1、回车:这是打印机术语,意思是将打印位置更改到当前行的开头。在计算机世界中,它在大多数情况下表示返回到当前行的开始,但很少表示新行。
2、换行:这是打印机术语,意思是把纸张往前行。因此换行和换行一起使用,在新行开始时开始打印。在计算机世界中,它通常与换行符具有相同的含义。
3、表单提要:这是一个打印机术语,我喜欢这个帖子中的解释。
如果您正在为一台20世纪80年代风格的打印机编程,它将弹出 纸,开始新的一页。你几乎可以肯定永远不需要 它。 http://en.wikipedia.org/wiki/Form_feed
它几乎已经过时了,你可以参考转义序列\f - form feed -它到底是什么?详细说明。
注意,我们可以在某些平台上使用CR或LF或CRLF来代表换行符,但在其他一些平台上它们不能代表换行符。详见wiki Newline。
LF: Multics, Unix and Unix-like systems (Linux, OS X, FreeBSD, AIX, Xenix, etc.), BeOS, Amiga, RISC OS, and others CR: Commodore 8-bit machines, Acorn BBC, ZX Spectrum, TRS-80, Apple II family, Oberon, the classic Mac OS up to version 9, MIT Lisp Machine and OS-9 RS: QNX pre-POSIX implementation 0x9B: Atari 8-bit machines using ATASCII variant of ASCII (155 in decimal) CR+LF: Microsoft Windows, DOS (MS-DOS, PC DOS, etc.), DEC TOPS-10, RT-11, CP/M, MP/M, Atari TOS, OS/2, Symbian OS, Palm OS, Amstrad CPC, and most other early non-Unix and non-IBM OSes LF+CR: Acorn BBC and RISC OS spooled text output.
其他回答
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来分隔而不是终止行。许多文本编辑器可以读取这三种格式中的任何一种格式的文件并在它们之间进行转换,但并非所有实用程序都可以。
表单提要不太常用。作为页面分隔符,它只能出现在行之间或文件的开始或结束处。
when I was an apprentice in the Royal Signals many (50) years ago, teletypes and typewriters had "Carriage" with the printing head on them. When you pressed RETURN the Carriage would fly to the left. Hence Carriage Return (CR). You could just return the Carriage, but on mechanical typewriters, you'd use the Lever (much like a tremolo lever on an electric guitar) which would also do the Line Feed. Your next question is why would you not want the line feed? heh heh well in those days to delete characters we'd do a CR then use a Tip-ex-like paper in between the hammerheads and paper and type the same keys to over-write with white ink. Some fancy typewriters had a key you could press. So there you go.
看看维基百科:
基于ASCII或兼容字符集的系统分别使用LF(换行,'\n', 0x0A,十进制10)或CR(回车,'\r', 0x0D,十进制13),或CR后跟LF (CR+LF, 0x0D 0x0A)。这些字符是基于打印机命令的:换行指示一行纸应该从打印机输出,回车指示打印机的回车应返回到当前行的开头。
这些是非印刷字符,与“新行”的概念有关。\n是换行。\r是回车。在不同的平台上,相对于有效的新行,它们有不同的含义。在windows中,新行是\r\n。在linux中,\n。在mac中,\r。
实际上,将它们放在任何字符串中,都会对字符串的打印结果产生影响。