zoukankan      html  css  js  c++  java
  • Difference between CR LF, LF and CR line break types?

    Difference between CR LF, LF and CR line break types?

    I'd like to know the difference (with examples if possible) between CR LF (Windows), LF (Unix) and CR (Macintosh) line break types.

    评论

    CR and LF are ASCII and Unicode control characters while and are abstractions used in certain programming languages. Closing this question glosses over fundamental differences between the questions and perpetuates misinformation.

    回答1

    CR and LF are control characters, respectively coded 0x0D (13 decimal) and 0x0A (10 decimal).

    They are used to mark a line break in a text file. As you indicated,

    Windows uses two characters the CR LF sequence;

    Unix only uses LF

    and the old MacOS ( pre-OSX MacIntosh) used CR.

    An apocryphal historical perspective:

    As indicated by Peter, CR = Carriage Return and LF = Line Feed, two expressions have their roots in the old typewriters / TTY. LF moved the paper up (but kept the horizontal position identical) and CR brought back the "carriage" so that the next character typed would be at the leftmost position on the paper (but on the same line). CR+LF was doing both, i.e. preparing to type a new line. As time went by the physical semantics of the codes were not applicable, and as memory and floppy disk space were at a premium, some OS designers decided to only use one of the characters, they just didn't communicate very well with one another ;-)

    Most modern text editors and text-oriented applications offer options/settings etc. that allow the automatic detection of the file's end-of-line convention and to display it accordingly.

    回答

    This is a good summary I found:

    The Carriage Return (CR) character (0x0D, ) moves the cursor to the beginning of the line without advancing to the next line. This character is used as a new line character in Commodore and Early Macintosh operating systems (OS-9 and earlier).

    The Line Feed (LF) character (0x0A, ) moves the cursor down to the next line without returning to the beginning of the line. This character is used as a new line character in UNIX based systems (Linux, Mac OSX, etc)

    The End of Line (EOL) sequence (0x0D 0x0A, ) is actually two ASCII characters, a combination of the CR and LF characters. It moves the cursor both down to the next line and to the beginning of that line. This character is used as a new line character in most other non-Unix operating systems including Microsoft Windows, Symbian OS and others.

    Source

    TortoiseDiff显示出来的区别

    001CarriageReturn.txt  换行符显示为<--

    002LineFeed.txt 换行符显示为向下的箭头

    003EndOfLine.txt  换行符显示为回车符号

    LabVIEW Termination Characters

     
  • 相关阅读:
    Cmake编译SDL2
    glog的使用
    win32下编译glog
    快速阅读《QT5.9 c++开发指南》1
    applyColorMap()研究(如果我对现有的colormap不满意,那么如何具体来做)
    如何判断轮廓是否为圆
    libopencv_shape.so.3.0: cannot open shared object file: No such file or directory 解决笔记
    OpenCV和RTSP的综合研究
    识别复杂的答题卡1(主要算法)
    识别简单的答题卡(Bubble sheet multiple choice scanner and test grader using OMR, Python and OpenCV——jsxyhelu重新整编)
  • 原文地址:https://www.cnblogs.com/chucklu/p/15309998.html
Copyright © 2011-2022 走看看