Carriage return

From WikiMD's Food, Medicine & Wellness Encyclopedia

Underwoodfive

Carriage Return (CR) is a control character in computing used to reset a device's position to the beginning of a line of text. Originating from the mechanical actions of typewriters, where the carriage holding the paper would return to its initial position after reaching the end of a line, the concept has been adapted into the digital realm. It is represented by the ASCII code 13 (0x0D in hexadecimal) and is often seen in combination with the Line Feed (LF) character in text files to denote the end of a line, especially in the context of Windows operating systems.

Usage[edit | edit source]

In the early days of computing, the carriage return was used in conjunction with the line feed character to prepare a printer or a screen for the next line of text. The CR would return the cursor to the beginning of the line, and the LF would advance the output to the next line. This combination is still used in modern operating systems like Windows, where the end of a line is marked by both CR and LF characters (CRLF). In contrast, Unix and Unix-like systems such as Linux and macOS use only the LF character to denote the end of a line, while older Macintosh systems used solely the CR character.

Programming and Data Formats[edit | edit source]

In programming languages, the carriage return character is often used within strings to represent the end of a line. For example, in C and languages that follow C syntax, such as C++, Java, and JavaScript, '\r' represents the CR character. Its usage varies depending on the operating system's convention for line endings in text files.

In data formats, especially in text-based formats like CSV (Comma-Separated Values), the CR character can be used to signify the end of a line, although the convention may vary depending on the system handling the data.

Historical Context[edit | edit source]

The carriage return's origins can be traced back to typewriters and teleprinters, where physically moving the carriage or print head back to the start of the line was necessary to continue typing or printing characters on a new line. As technology evolved, the concept was incorporated into computer terminals and printers, maintaining the metaphor of the carriage's movement.

Modern Relevance[edit | edit source]

While the physical action of returning a carriage is no longer necessary in digital devices, the carriage return character remains a fundamental part of text processing and data representation in computing. Its significance is particularly noted in the context of cross-platform software development, where understanding the differences in line-ending conventions is crucial for ensuring compatibility and proper data interpretation across different operating systems.

See Also[edit | edit source]

Wiki.png

Navigation: Wellness - Encyclopedia - Health topics - Disease Index‏‎ - Drugs - World Directory - Gray's Anatomy - Keto diet - Recipes

Search WikiMD


Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro) available.
Advertise on WikiMD

WikiMD is not a substitute for professional medical advice. See full disclaimer.

Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.


Contributors: Prab R. Tumpati, MD