Order of carriage return and new line feed

后端 未结 5 1419
抹茶落季
抹茶落季 2020-12-13 09:23

Is it important to have the correct order of carriage return then new line feed? For text editors does it matter in what order they appear?

For example instead of

5条回答
  •  温柔的废话
    2020-12-13 09:37

    There are three common linefeed formats:

    • \r\n for the DOS\Windows world
    • \r for the pre-OSX Mac world
    • \n for the Unix and Unix-like world

    \n\r is not a standard anywhere that I'm aware of and will likely result in your editor thinking that it has a Unix-format text file, and then it'll display the weird \r character as text.

    Historically, \r translates to carriage return (CR, ASCII code 13) which refers to old school typewriter, where you would push the carriage back to the left to return the cursor back to the start of the line. \n translates to line feed (LF, ASCII code 10) which moves the character down the page one character. Although potentially interesting, it generally doesn't matter — just use the appropriate linefeed format for your current platform.

提交回复
热议问题