What is a \r" and why would one use it with a \n?

前端 未结 3 500
滥情空心
滥情空心 2020-12-24 02:31

What is the difference between this two strings?

\"first line \\n second line\" , \"first line \\r\\n second line\"

相关标签:
3条回答
  • 2020-12-24 03:11

    the difference is in the different EOL system (Unix like first, Win/DOS second)

    see http://en.wikipedia.org/wiki/Newline

    0 讨论(0)
  • 2020-12-24 03:22

    \r - Carriage Return
    \n - Line Feed

    \r\n is often used in preference to \n as it displays properly on both unix and Windows.

    Carriage Return just returns the cursor to the beginning of the same line (without advancing to the next line) whereas a Line Feed feeds a new line.

    Note: (hover over the grey box below to find out)

    If you ever get hold of a typewriter, try using it. It is such a magnificent piece of engineering which not many get to experience these days.

    0 讨论(0)
  • 2020-12-24 03:26

    Its the newline representation for different operating systems. In windows a new line is \r\n and Linux its \n.

    0 讨论(0)
提交回复
热议问题