问题描述
我知道每种操作系统都不同,例如,在Windows中可能会期望"\ r \ n",在Unix中可能会期望"\ n \ n",在Mac中可能会期望"\ r".
I understand that it's different for each operating System, for example, "\r\n" may be expected in Windows, "\n" may be expected in Unix snd "\r" may be expected in Macs.
这两个(或三个,如果要包括"\ r \ n")转义序列之间有什么区别?为什么在所有系统上不一致?
What are the differences between these two (or three, if you want to include "\r\n") escape sequences? Why isn't it consistent across all systems?
我对此很好奇.
推荐答案
因为不是.
\ r表示回车".\ n表示""换行符
\r means "carriage return".\n means "" line feed
某些系统足够聪明,建议将光标移到新行所需要的全部是\n
.其他人认为走\r\n
更合适,因为他们可能声称列位置也需要重设(即\r
).
Some systems are wise enough to suggest that all they need to get the cursor to a new line is \n
. Others think that it's more appropriate to go \r\n
, because, they may claim that the column position needs to be reset as well (i.e. the \r
).
有时在计算事物时,就是这样".这是其中一种情况:)
Sometimes in computing things are 'just this way'. This is one of those cases :)
这篇关于"\ r"和"\ r"之间有什么区别?和"\ n"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!