What are carriage return, linefeed, and form feed?

后端 未结 12 1537
我寻月下人不归
我寻月下人不归 2020-11-22 14:26

What is the meaning of the following control characters:

  1. Carriage return

  2. Line feed

  3. Form feed

12条回答
  •  Happy的楠姐
    2020-11-22 15:18

    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.

    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.

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

    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.

    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.

    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.

    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.

提交回复
热议问题