What is the difference between \n and \r\nline breaks?
\nThere is an environment where it doesn't work.
\n
is the LF character (Line Feed) and \r
is the control character called the carriage return.
There are three ways to express a new line of text, depending on the system:The representative OS using that expression method is also included.
\n
(LF): Unix-based OS in general, Mac OS X\r\n
(CR+LF):Windows OS\r
(CR):Old Mac OS (9 and earlier)Although it is natural to use \n
single characters as expressions on your computer, there is a historical history of using \r\n
originally derived from a typewriter. (CR moves the printer back to the left + LF scrolls a line of paper)
Communication protocols tend to use CRLF (\r\n).For example, HTTP and mail protocols specify CRLF as the newline code.
UNIX operating systems use \n
and
Microsoft operating systems use \r\n
.
\r\n
is usually converted to \n
, so there is no problem
For binary handling or
This can be a problem if you are trying to run UNIX-like OSes like Cygwin.
© 2024 OneMinuteCode. All rights reserved.