Jump to content

Carriage return

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 12.197.7.22 (talk) at 17:05, 7 January 2011 (See also). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Carriage return, often shortened to return, refers to a control character used when starting a new line of text.

Originally, the term "carriage return" referred to a mechanism or lever on a typewriter. It was used after typing a line of text and caused the assembly holding the paper (the carriage) to return to the right (assuming a left-to-right language), so the machine was ready to type again on the left side of the paper. The lever would also usually advance the paper to the next line. Later the term "carriage return" was used for the control character in Baudot code on a teletypewriter calling for a return to the beginning of the line (and not including the line feed).[1] The first power carriage return was added to electric typewriters by Smith Corona in 1960. The key for this was usually labelled "carriage return" or "return". With typewriters like the Selectric, where the type element was moved when typing and the paper held stationary, the key returned the type element to the left and the term "carrier return" was sometimes used for this function.

To improve the keyboard for non-English-speakers, the symbol ↵ (U+21B5) was introduced to mark this key, since this graphic could communicate the action of the key without using words.

Computers

In computing, the carriage return (CR) is one of the control characters in ASCII code, Unicode or EBCDIC that commands a printer or other sort of display to move the position of the cursor to the first position on the same line. It was mostly used along with line feed, a move to the next line, while carriage return precedes line feed to indicate a new line. The term derives from the above usage, as early printers often closely resembled typewriters; this control character would activate a physical carriage-return mechanism.

On printers, teletypes, and computer terminals that were not capable of displaying graphics, the carriage return was used without moving to the next line to allow characters to be placed on top of existing characters to produce character graphics, underlines, and crossed out text.

Many computer programs use the carriage return character, alone or with a line feed, to signal the end of a line of text, but other characters are also used for this function (see newline); others use it only for a paragraph break (a hard return). Some standards which introduce their own representations for line and paragraph control (for example HTML) treat carriage return and line feed as whitespace.

In ASCII and Unicode, the character code decimal 13 (or hexadecimal 0D) is defined to be carriage return, it may also be seen as control+M or ^M. In the C programming language, and many other languages influenced by it, \r denotes this character.[2]

User interface functionality

On Windows, Macintosh and most other GUI operating systems, hitting the return key also results in the default option of a dialog box (usually OK or Yes) being selected.

Mac OS provides differentiation between the 'return' key and 'enter' key, while Microsoft Windows does not. Though used interchangeably today, the Return key and Enter key on PC keyboards actually send different scan codes, and so can be programmed for different uses.

Summary

  • Keys commonly generating the character "carriage return":
    "Enter" key
    "Return" key
    ↵ key
    Control-M
  • ASCII and Unicode representation of "carriage return":
    Decimal code: 13
    Hexadecimal code: 0D
    Symbol: CR
  • Programming escape codes and functions for generating a "carriage return":
    PHP, Python, Bash, C/C++, C#, Java, Javascript, Perl, Ruby: \r
    Visual Basic (VB), VBA and VB.NET: vbCr or Chr$(13)
    CFML: Chr(13)
    XML (HTML, XSLT): 
  • Microsoft Office "carriage return":
    Word: Shift-Enter
    "Find & Replace" regular expression: ^p
    "Find & Replace" alternative expression: ^013
    "Find & Replace" expression for a "manual return": ^l
    Excel: Alt-Enter (Win) Cmd-Opt-Enter (OSX)
  • OpenOffice.org "carriage return":
    Writer in "Find & Replace" regular expression: $
    OpenOffice.org basic also uses Chr(13)[3]

See also

References

  1. ^ This is the origin of the computing term CRLF, which stands for "carriage return [and] line feed".
  2. ^ Eric S. Roberts. The Art and Science of C. Addison-Wesley, 1995. p311.
  3. ^ http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Basic/String_Functions
Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 PrtScn/
SysRq
Scroll
Lock
Pause/
Break
TildeExclamation markAt signNumber signDollar signPercent signCaretAmpersandAsteriskParenthesisParenthesisUnderscorePlus signBackspaceBacktick1 (number)2 (number)3 (number)4 (number)5 (number)6 (number)7 (number)8 (number)9 (number)0Hyphen-minusEquals signBackspaceTab keyQWERTYUIOPCurly bracketCurly bracketVertical barTab keyQWERTYUIOPSquare bracketSquare bracketBackslashCaps lockASDFGHJKLColon (punctuation)Quotation markEnter keyCaps lockASDFGHJKLSemicolonApostropheEnter keyShift keyZXCVBNMBracketBracketQuestion markShift keyShift keyZXCVBNMComma (punctuation)Full stopSlash (punctuation)Shift keyControl keyWindows keyAlt keySpace barAlt keyWindows keyMenu keyControl key
Insert Home PgUp Num
Lock
Delete End PgDn 7 8 9 +
4 5 6
1 2 3 Enter
   0
   Ins
 . 
Del