There are 3 kinds of line breaks
- \r
- \n
- \r\n
For windows, \r\n is standard.
Suppose that there is a file called document.txt, using \r or \r\n as line breaks.
Suppose that I open document.txt with a notepad program and select all text and Ctrl+C,
then create a string variable named mystring, in mathematica.
In[1] mystring="paste, I mean ctrl+V here."
(note that the content of mystring is several lines.)
Then
In[2] StringCount[mystring, "\r"]
Out[2] 0
Looks like \r or \r\n are all replaced with \n automatically.
Q1) Does mathematica automatically change line breaks to \n?
It is a little surprising that mathematica, doesn't prohibit to use \r.
If you type '\r' with your fingers, when defining a string variable, it works.
Looks like unwanted line breaks change (every line break to \n) happen only when pasting clipboard content to mathematica.
Q2) Why does mathematica behave like this ? Is there an option to correct this phenomenon?
About comment :
Thank you Ben Izd, but in my PC,
ReadString doesn't replace \n with \r\n.
Evidence :
And the result of opening file3.txt in notepad++ is, just 2 lilnes, not 3 lines.