什么是回车、换行和形式馈送?

时间:2021-06-28 00:06:32

What is the meaning of the following control characters:

以下控制字符的含义是:

  1. Carriage return

    回车

  2. Line feed

    换行

  3. Form feed

    换页

11 个解决方案

#1


467  

Carriage return means to return to the beginning of the current line without advancing downward. The name comes from a printer's carriage, as monitors were rare when the name was coined. This is commonly escaped as "\r", abbreviated CR, and has ASCII value 13 or 0x0D.

回车的意思是返回到当前行的起点,而不向下移动。这个名字来自于打印机的车厢,当这个名字被创造出来的时候,监视器是很少见的。这通常是“\r”,缩写的CR,并有ASCII值13或0x0D。

Linefeed means to advance downward to the next line; however, it has been repurposed and renamed. Used as "newline", it terminates lines (commonly confused with separating lines). This is commonly escaped as "\n", abbreviated LF or NL, and has ASCII value 10 or 0x0A. CRLF (but not CRNL) is used for the pair "\r\n".

Linefeed的意思是向下移动到下一行;然而,它已经被重新定义并重新命名。用作“换行”,它终止行(通常与分隔线混淆)。这通常是“\n”,缩写为LF或NL,并有ASCII值10或0x0A。CRLF(但不是CRNL)用于这对“\r\n”。

Form feed means advance downward to the next "page". It was commonly used as page separators, but now is also used as section separators. (It's uncommonly used in source code to divide logically independent functions or groups of functions.) Text editors can use this character when you "insert a page break". This is commonly escaped as "\f", abbreviated FF, and has ASCII value 12 or 0x0C.

表单提要意味着向下进入下一个“页面”。它通常被用作页面分隔符,但现在也用作分区分隔符。(在源代码中不常用来划分逻辑上独立的函数或函数组。)当你“插入分页符”时,文本编辑器可以使用这个字符。这通常是“\f”,缩写FF,并有ASCII值12或0x0C。

As control characters, they may be interpreted in various ways.

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

The most common difference (and probably the only one worth worrying about) is lines end with CRLF on Windows, NL on Unix-likes, and CR on older Macs (the situation has changed with OS X to be like Unix). Note the shift in meaning from LF to NL, for the exact same character, gives the differences between Windows and Unix. (Windows is, of course, newer than Unix, so it didn't adopt this semantic shift. I don't know the history of Macs using CR.) Many text editors can read files in any of these three formats and convert between them, but not all utilities can.

最常见的区别(可能也是唯一值得担心的)是在Windows上使用CRLF的行,在Unix上的NL,以及在旧的mac上的CR(这种情况随OS X的变化而变成了Unix)。请注意,从LF到NL的含义的转换,对于完全相同的字符,给出了Windows和Unix之间的区别。(当然,Windows比Unix更新,所以它没有采用这种语义转换。我不知道mac使用CR的历史。)许多文本编辑器可以读取这三种格式中的任意一种格式,并在它们之间进行转换,但不是所有的实用程序都可以。

Form feed is a bit more interesting (even though less commonly used directly), and with the usual definition of page separator, it can only come between lines (e.g. after the newline sequence of NL, CRLF, or CR) or at the start or end of the file.

表单提要更有趣(尽管很少直接使用),并且通常定义页面分隔符,它只能在行之间(例如,在NL、CRLF或CR的换行序列之后)或在文件的开头或结尾。

#2


70  

\r is carriage return and moves the cursor back like if i will do-

\r是回车,并把光标移回来,就像我要做的一样。

printf("*\rnine")
ninekoverflow

means it has shifted the cursor to the beginning of "*" and overwrites the starting four characters since "nine" is four character long.

意味着它将光标移到“*”的开头,并改写了从“9”到“9”的四个字符。

\n is new line character which changes the line and takes the cursor to the beginning of a new line like-

\n是一个新的行字符,它改变了线条,并将光标移到一个新行的开头,比如-。

printf("*\nnine")
*
nine

\f is form feed, its use has become obsolete but it is used for giving indentation like

\f是表单提要,它的使用已经过时了,但它是用来给缩进的。

printf("*\fnine")
*
             nine

if i will write like-

如果我写成。

printf("*\fnine\fgreat")
*
             nine
                 great

#3


25  

\f is used for page break. You cannot see any effect in the console. But when you use this character constant in your file then you can see the difference.

\f用于分页符。您无法在控制台中看到任何效果。但是当你在你的文件中使用这个字符常量时,你就能看到区别了。

Other example is that if you can redirect your output to a file then you don't have to write a file or use file handling.

另一个例子是,如果您可以将您的输出重定向到一个文件,那么您就不必编写一个文件或使用文件处理。

For ex:

为例:

Write this code in c++

用c++编写这段代码。

void main()    
{
    clrscr();
    cout<<"helloooooo" ;

    cout<<"\f";
    cout<<"hiiiii" ;

}

and when you compile this it generate an exe(for ex. abc.exe)

当你编译它时,它会生成exe(for ex. abc.exe)

then you can redirect your output to a file using this:

然后,您可以使用以下方法将输出重定向到文件:

abc > xyz.doc

美国广播公司(abc)> xyz.doc

then open the file xyz.doc you can see the actual page break between hellooo and hiiii....

然后打开文件xyz。你可以看到hellooo和hiiii之间的实际分页

#4


22  

Have a look at Wikipedia:

看看*:

Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A). These characters are based on printer commands: The line feed indicated that one line of paper should feed out of the printer, and a carriage return indicated that the printer carriage should return to the beginning of the current line.

基于ASCII或兼容字符集的系统可以使用LF(行馈线,'\n', 0x0A, 10 in decimal)或CR(回车,'\r', 0x0D, 13 in decimal),或CR后跟LF (CR+LF, 0x0D 0x0A)。这些字符是基于打印机命令的:行提要显示,一行文件应该从打印机中输出,而回车返回指示打印机应返回到当前行的开头。

#5


16  

Apart from above information, there is still an interesting history of LF (\n) and CR (\r). [Original author : 阮一峰 Source : http://www.ruanyifeng.com/blog/2006/04/post_213.html] Before computer came out, there was a type of teleprinter called Teletype Model 33. It can print 10 characters each second. But there is one problem with this, after finishing printing each line, it will take 0.2 second to move to next line, which is time of printing 2 characters. If a new characters is transferred during this 0.2 second, then this new character will be lost.

除了以上信息外,还有LF (\n)和CR (\r)的有趣历史。(原作者:阮一峰来源:http://www.ruanyifeng.com/blog/2006/04/post_213.html]计算机出来之前,有一种叫做电传打字机的电传打字机模型33。它可以每秒钟打印10个字符。但是有一个问题,在完成打印每一行之后,需要0.2秒才能移动到下一行,这是打印两个字符的时间。如果在这0.2秒内传输一个新字符,那么这个新字符将丢失。

So scientists found a way to solve this problem, they add two ending characters after each line, one is 'Carriage return', which is to tell the printer to bring the print head to the left.; the other one is 'Line feed', it tells the printer to move the paper up 1 line.

所以科学家们找到了解决这个问题的方法,他们在每行之后加两个结束字符,一个是“回车”,也就是告诉打印机把打印头移到左边。另一个是“换行”,它告诉打印机将纸张向上移动一行。

Later, computer became popular, these two concepts are used on computers. At that time, the storage device was very expensive, so some scientists said that it was expensive to add two characters at the end of each line, one is enough, so there are some arguments about which one to use.

后来,电脑变得流行起来,这两个概念被用在电脑上。当时,存储设备非常昂贵,所以一些科学家说,在每行的末尾添加两个字符是很昂贵的,一个就足够了,所以有一些关于该使用哪个的争论。

In UNIX/Mac and Linux, '\n' is put at the end of each line, in Windows, '\r\n' is put at the end of each line. The consequence of this use is that files in UNIX/Mac will be displayed in one line if opened in Windows. While file in Windows will have one ^M at the end of each line if opened in UNIX or Mac.

在UNIX/Mac和Linux中,“\n”被放在每行的末尾,在Windows中,“\r\n”被放在每一行的末尾。这种使用的结果是,如果在Windows中打开,UNIX/Mac中的文件将在一行中显示。在Windows文件一^ M的每一行,如果在UNIX和Mac。

#6


13  

On old paper-printer terminals, advancing to the next line involved two actions: moving the print head back to the beginning of the horizontal scan range (carriage return) and advancing the roll of paper being printed on (line feed).

在旧的纸打印机终端机上,推进到下一行涉及两个动作:将打印头移回水平扫描范围的起点(回车),并推进打印在(换行)上的纸卷。

Since we no longer use paper-printer terminals, those actions aren't really relevant anymore, but the characters used to signal them have stuck around in various incarnations.

由于我们不再使用纸质打印机终端,这些操作不再是真正意义上的相关,而是用来指示它们的字符在不同的化身中存在。

#7


10  

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.

考虑一下IBM 1403的影响打印机。CR将打印头移到行开始处,但没有将打印头推进。这允许“过度打印”,在一行上放置多个输出行。像粗体印刷这样的东西是通过这种方式实现的。LF将纸向前推进一行。如果没有CR,下一行将打印为交错的步骤,因为LF没有移动打印头。FF把论文推进到下一页。它通常也将打印头移到新页面的第一行的开头,但是您可能需要使用CR。可以肯定的是,大多数程序员在最后一行末尾的crf中编码CRFF而不是CRLF,因为由FF创建的额外的CR并不重要。

#8


5  

As a supplement,

作为一个补充,

1, Carriage return: It's a printer terminology meaning changing the print location to the beginning of current line. In computer world, it means return to the beginning of current line in most cases but stands for new line rarely.

1、回车:是打印机术语,意思是将打印位置更改为当前行的开始位置。在计算机世界中,它意味着在大多数情况下返回到当前行的起始位置,但很少代表新行。

2, Line feed: It's a printer terminology meaning advancing the paper one line. So Carriage return and Line feed are used together to start to print at the beginning of a new line. In computer world, it generally has the same meaning as newline.

2、换行:这是一个印刷术语,意思是把纸向前推进一行。因此,回车和换行一起使用,开始在新行开始时打印。在计算机世界中,它通常具有与换行相同的含义。

3, Form feed: It's a printer terminology, I like the explanation in this thread.

3、表单提要:这是一个打印机术语,我喜欢这个线程的解释。

If you were programming for a 1980s-style printer, it would eject the paper and start a new page. You are virtually certain to never need it.

如果您正在为一个80年代风格的打印机编程,它将弹出文件并开始一个新的页面。你几乎肯定不需要它。

http://en.wikipedia.org/wiki/Form_feed

http://en.wikipedia.org/wiki/Form_feed

It's almost obsolete and you can refer to Escape sequence \f - form feed - what exactly is it? for detailed explanation.

它几乎已经过时了,你可以参考Escape序列\f - form feed——它到底是什么?详细的解释。

Note, we can use CR or LF or CRLF to stand for newline in some platforms but newline can't be stood by them in some other platforms. Refer to wiki Newline for details.

请注意,我们可以使用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

LF: Multics、Unix和Unix类系统(Linux、OS X、FreeBSD、AIX、Xenix等)、BeOS、Amiga、RISC OS等。

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

CR: Commodore 8位机,Acorn BBC, ZX Spectrum, TRS-80, Apple II家庭,Oberon,经典的Mac OS到version 9, MIT Lisp机器和OS-9。

RS: QNX pre-POSIX implementation

拉尔夫-舒马赫:QNX pre-POSIX实现

0x9B: Atari 8-bit machines using ATASCII variant of ASCII (155 in decimal)

0x9B: Atari 8位机器使用美国ASCII码的ASCII码(十进制的155)

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

CR+LF: Microsoft Windows, DOS (MS-DOS, PC DOS等),DEC TOPS-10, RT-11, CP/M, MP/M, Atari TOS, OS/2, Symbian OS, Palm OS, Amstrad CPC,以及其他大多数早期非unix和非ibm OSes。

LF+CR: Acorn BBC and RISC OS spooled text output.

LF+CR: Acorn BBC和RISC OS spooled文本输出。

#9


3  

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

回车和换行也是对打字机的参考,在车的左边有一个小推力(纸的位置),纸会绕着圆筒旋转一个小的量,把文件的一个线向前推进。如果你已经完成了一行,并且想要继续下一个,你就会更用力,向前推进一行,然后滑到右边,然后在每一次击键的时候,再从左移到右。不用说,文字包装是这个时代所有文字处理的默认设置。P:D

#10


2  

"\n" is the linefeed character. It means end the present line and go to a new line for anyone who is reading it.

“\n”是linefeed字符。它的意思是结束现在的线路,并为任何正在阅读它的人提供一条新的线路。

#11


1  

Those are non-printing characters, relating to the concept of "new line". \n is linefeed. \r is carriage return. On different platforms they have different meanings, relative to a valid new line. In windows, a new line is \r\n. In linux, \n. In mac, \r.

这些都是非印刷字符,与“新线路”的概念有关。\ n是换行。\ r是回车。在不同的平台上,它们有不同的含义,相对于一条有效的新线路。在windows中,新行是\r\n。在linux中,\ n。在mac \ r。

In practice, you put them in any string, and it will have effect on the print-out of the string.

在实践中,您将它们放入任何字符串中,它将对字符串的打印输出产生影响。

#1


467  

Carriage return means to return to the beginning of the current line without advancing downward. The name comes from a printer's carriage, as monitors were rare when the name was coined. This is commonly escaped as "\r", abbreviated CR, and has ASCII value 13 or 0x0D.

回车的意思是返回到当前行的起点,而不向下移动。这个名字来自于打印机的车厢,当这个名字被创造出来的时候,监视器是很少见的。这通常是“\r”,缩写的CR,并有ASCII值13或0x0D。

Linefeed means to advance downward to the next line; however, it has been repurposed and renamed. Used as "newline", it terminates lines (commonly confused with separating lines). This is commonly escaped as "\n", abbreviated LF or NL, and has ASCII value 10 or 0x0A. CRLF (but not CRNL) is used for the pair "\r\n".

Linefeed的意思是向下移动到下一行;然而,它已经被重新定义并重新命名。用作“换行”,它终止行(通常与分隔线混淆)。这通常是“\n”,缩写为LF或NL,并有ASCII值10或0x0A。CRLF(但不是CRNL)用于这对“\r\n”。

Form feed means advance downward to the next "page". It was commonly used as page separators, but now is also used as section separators. (It's uncommonly used in source code to divide logically independent functions or groups of functions.) Text editors can use this character when you "insert a page break". This is commonly escaped as "\f", abbreviated FF, and has ASCII value 12 or 0x0C.

表单提要意味着向下进入下一个“页面”。它通常被用作页面分隔符,但现在也用作分区分隔符。(在源代码中不常用来划分逻辑上独立的函数或函数组。)当你“插入分页符”时,文本编辑器可以使用这个字符。这通常是“\f”,缩写FF,并有ASCII值12或0x0C。

As control characters, they may be interpreted in various ways.

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

The most common difference (and probably the only one worth worrying about) is lines end with CRLF on Windows, NL on Unix-likes, and CR on older Macs (the situation has changed with OS X to be like Unix). Note the shift in meaning from LF to NL, for the exact same character, gives the differences between Windows and Unix. (Windows is, of course, newer than Unix, so it didn't adopt this semantic shift. I don't know the history of Macs using CR.) Many text editors can read files in any of these three formats and convert between them, but not all utilities can.

最常见的区别(可能也是唯一值得担心的)是在Windows上使用CRLF的行,在Unix上的NL,以及在旧的mac上的CR(这种情况随OS X的变化而变成了Unix)。请注意,从LF到NL的含义的转换,对于完全相同的字符,给出了Windows和Unix之间的区别。(当然,Windows比Unix更新,所以它没有采用这种语义转换。我不知道mac使用CR的历史。)许多文本编辑器可以读取这三种格式中的任意一种格式,并在它们之间进行转换,但不是所有的实用程序都可以。

Form feed is a bit more interesting (even though less commonly used directly), and with the usual definition of page separator, it can only come between lines (e.g. after the newline sequence of NL, CRLF, or CR) or at the start or end of the file.

表单提要更有趣(尽管很少直接使用),并且通常定义页面分隔符,它只能在行之间(例如,在NL、CRLF或CR的换行序列之后)或在文件的开头或结尾。

#2


70  

\r is carriage return and moves the cursor back like if i will do-

\r是回车,并把光标移回来,就像我要做的一样。

printf("*\rnine")
ninekoverflow

means it has shifted the cursor to the beginning of "*" and overwrites the starting four characters since "nine" is four character long.

意味着它将光标移到“*”的开头,并改写了从“9”到“9”的四个字符。

\n is new line character which changes the line and takes the cursor to the beginning of a new line like-

\n是一个新的行字符,它改变了线条,并将光标移到一个新行的开头,比如-。

printf("*\nnine")
*
nine

\f is form feed, its use has become obsolete but it is used for giving indentation like

\f是表单提要,它的使用已经过时了,但它是用来给缩进的。

printf("*\fnine")
*
             nine

if i will write like-

如果我写成。

printf("*\fnine\fgreat")
*
             nine
                 great

#3


25  

\f is used for page break. You cannot see any effect in the console. But when you use this character constant in your file then you can see the difference.

\f用于分页符。您无法在控制台中看到任何效果。但是当你在你的文件中使用这个字符常量时,你就能看到区别了。

Other example is that if you can redirect your output to a file then you don't have to write a file or use file handling.

另一个例子是,如果您可以将您的输出重定向到一个文件,那么您就不必编写一个文件或使用文件处理。

For ex:

为例:

Write this code in c++

用c++编写这段代码。

void main()    
{
    clrscr();
    cout<<"helloooooo" ;

    cout<<"\f";
    cout<<"hiiiii" ;

}

and when you compile this it generate an exe(for ex. abc.exe)

当你编译它时,它会生成exe(for ex. abc.exe)

then you can redirect your output to a file using this:

然后,您可以使用以下方法将输出重定向到文件:

abc > xyz.doc

美国广播公司(abc)> xyz.doc

then open the file xyz.doc you can see the actual page break between hellooo and hiiii....

然后打开文件xyz。你可以看到hellooo和hiiii之间的实际分页

#4


22  

Have a look at Wikipedia:

看看*:

Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A). These characters are based on printer commands: The line feed indicated that one line of paper should feed out of the printer, and a carriage return indicated that the printer carriage should return to the beginning of the current line.

基于ASCII或兼容字符集的系统可以使用LF(行馈线,'\n', 0x0A, 10 in decimal)或CR(回车,'\r', 0x0D, 13 in decimal),或CR后跟LF (CR+LF, 0x0D 0x0A)。这些字符是基于打印机命令的:行提要显示,一行文件应该从打印机中输出,而回车返回指示打印机应返回到当前行的开头。

#5


16  

Apart from above information, there is still an interesting history of LF (\n) and CR (\r). [Original author : 阮一峰 Source : http://www.ruanyifeng.com/blog/2006/04/post_213.html] Before computer came out, there was a type of teleprinter called Teletype Model 33. It can print 10 characters each second. But there is one problem with this, after finishing printing each line, it will take 0.2 second to move to next line, which is time of printing 2 characters. If a new characters is transferred during this 0.2 second, then this new character will be lost.

除了以上信息外,还有LF (\n)和CR (\r)的有趣历史。(原作者:阮一峰来源:http://www.ruanyifeng.com/blog/2006/04/post_213.html]计算机出来之前,有一种叫做电传打字机的电传打字机模型33。它可以每秒钟打印10个字符。但是有一个问题,在完成打印每一行之后,需要0.2秒才能移动到下一行,这是打印两个字符的时间。如果在这0.2秒内传输一个新字符,那么这个新字符将丢失。

So scientists found a way to solve this problem, they add two ending characters after each line, one is 'Carriage return', which is to tell the printer to bring the print head to the left.; the other one is 'Line feed', it tells the printer to move the paper up 1 line.

所以科学家们找到了解决这个问题的方法,他们在每行之后加两个结束字符,一个是“回车”,也就是告诉打印机把打印头移到左边。另一个是“换行”,它告诉打印机将纸张向上移动一行。

Later, computer became popular, these two concepts are used on computers. At that time, the storage device was very expensive, so some scientists said that it was expensive to add two characters at the end of each line, one is enough, so there are some arguments about which one to use.

后来,电脑变得流行起来,这两个概念被用在电脑上。当时,存储设备非常昂贵,所以一些科学家说,在每行的末尾添加两个字符是很昂贵的,一个就足够了,所以有一些关于该使用哪个的争论。

In UNIX/Mac and Linux, '\n' is put at the end of each line, in Windows, '\r\n' is put at the end of each line. The consequence of this use is that files in UNIX/Mac will be displayed in one line if opened in Windows. While file in Windows will have one ^M at the end of each line if opened in UNIX or Mac.

在UNIX/Mac和Linux中,“\n”被放在每行的末尾,在Windows中,“\r\n”被放在每一行的末尾。这种使用的结果是,如果在Windows中打开,UNIX/Mac中的文件将在一行中显示。在Windows文件一^ M的每一行,如果在UNIX和Mac。

#6


13  

On old paper-printer terminals, advancing to the next line involved two actions: moving the print head back to the beginning of the horizontal scan range (carriage return) and advancing the roll of paper being printed on (line feed).

在旧的纸打印机终端机上,推进到下一行涉及两个动作:将打印头移回水平扫描范围的起点(回车),并推进打印在(换行)上的纸卷。

Since we no longer use paper-printer terminals, those actions aren't really relevant anymore, but the characters used to signal them have stuck around in various incarnations.

由于我们不再使用纸质打印机终端,这些操作不再是真正意义上的相关,而是用来指示它们的字符在不同的化身中存在。

#7


10  

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.

考虑一下IBM 1403的影响打印机。CR将打印头移到行开始处,但没有将打印头推进。这允许“过度打印”,在一行上放置多个输出行。像粗体印刷这样的东西是通过这种方式实现的。LF将纸向前推进一行。如果没有CR,下一行将打印为交错的步骤,因为LF没有移动打印头。FF把论文推进到下一页。它通常也将打印头移到新页面的第一行的开头,但是您可能需要使用CR。可以肯定的是,大多数程序员在最后一行末尾的crf中编码CRFF而不是CRLF,因为由FF创建的额外的CR并不重要。

#8


5  

As a supplement,

作为一个补充,

1, Carriage return: It's a printer terminology meaning changing the print location to the beginning of current line. In computer world, it means return to the beginning of current line in most cases but stands for new line rarely.

1、回车:是打印机术语,意思是将打印位置更改为当前行的开始位置。在计算机世界中,它意味着在大多数情况下返回到当前行的起始位置,但很少代表新行。

2, Line feed: It's a printer terminology meaning advancing the paper one line. So Carriage return and Line feed are used together to start to print at the beginning of a new line. In computer world, it generally has the same meaning as newline.

2、换行:这是一个印刷术语,意思是把纸向前推进一行。因此,回车和换行一起使用,开始在新行开始时打印。在计算机世界中,它通常具有与换行相同的含义。

3, Form feed: It's a printer terminology, I like the explanation in this thread.

3、表单提要:这是一个打印机术语,我喜欢这个线程的解释。

If you were programming for a 1980s-style printer, it would eject the paper and start a new page. You are virtually certain to never need it.

如果您正在为一个80年代风格的打印机编程,它将弹出文件并开始一个新的页面。你几乎肯定不需要它。

http://en.wikipedia.org/wiki/Form_feed

http://en.wikipedia.org/wiki/Form_feed

It's almost obsolete and you can refer to Escape sequence \f - form feed - what exactly is it? for detailed explanation.

它几乎已经过时了,你可以参考Escape序列\f - form feed——它到底是什么?详细的解释。

Note, we can use CR or LF or CRLF to stand for newline in some platforms but newline can't be stood by them in some other platforms. Refer to wiki Newline for details.

请注意,我们可以使用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

LF: Multics、Unix和Unix类系统(Linux、OS X、FreeBSD、AIX、Xenix等)、BeOS、Amiga、RISC OS等。

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

CR: Commodore 8位机,Acorn BBC, ZX Spectrum, TRS-80, Apple II家庭,Oberon,经典的Mac OS到version 9, MIT Lisp机器和OS-9。

RS: QNX pre-POSIX implementation

拉尔夫-舒马赫:QNX pre-POSIX实现

0x9B: Atari 8-bit machines using ATASCII variant of ASCII (155 in decimal)

0x9B: Atari 8位机器使用美国ASCII码的ASCII码(十进制的155)

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

CR+LF: Microsoft Windows, DOS (MS-DOS, PC DOS等),DEC TOPS-10, RT-11, CP/M, MP/M, Atari TOS, OS/2, Symbian OS, Palm OS, Amstrad CPC,以及其他大多数早期非unix和非ibm OSes。

LF+CR: Acorn BBC and RISC OS spooled text output.

LF+CR: Acorn BBC和RISC OS spooled文本输出。

#9


3  

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

回车和换行也是对打字机的参考,在车的左边有一个小推力(纸的位置),纸会绕着圆筒旋转一个小的量,把文件的一个线向前推进。如果你已经完成了一行,并且想要继续下一个,你就会更用力,向前推进一行,然后滑到右边,然后在每一次击键的时候,再从左移到右。不用说,文字包装是这个时代所有文字处理的默认设置。P:D

#10


2  

"\n" is the linefeed character. It means end the present line and go to a new line for anyone who is reading it.

“\n”是linefeed字符。它的意思是结束现在的线路,并为任何正在阅读它的人提供一条新的线路。

#11


1  

Those are non-printing characters, relating to the concept of "new line". \n is linefeed. \r is carriage return. On different platforms they have different meanings, relative to a valid new line. In windows, a new line is \r\n. In linux, \n. In mac, \r.

这些都是非印刷字符,与“新线路”的概念有关。\ n是换行。\ r是回车。在不同的平台上,它们有不同的含义,相对于一条有效的新线路。在windows中,新行是\r\n。在linux中,\ n。在mac \ r。

In practice, you put them in any string, and it will have effect on the print-out of the string.

在实践中,您将它们放入任何字符串中,它将对字符串的打印输出产生影响。