windows与unix换行符的区别

2025-05-23 13:50:43
推荐回答(3个)
回答1:

Windows的换行符实际是两个字节,\CR\LF
而unix的换行符只需要一个\CR.

回答2:

参考wiki
Common problems

The different newline conventions often cause text files that have been transferred between systems of different types to be displayed incorrectly. For example, files originating on Unix or Apple Macintosh systems may appear as a single long line on some Windows programs. Conversely, when viewing a file originating from a Windows computer on a Unix system, the extra CR may be displayed as ^M at the end of each line or as a second line break.

上面说的是多余的CR显示成^M

LF: Line Feed, U+000A
CR: Carriage Return, U+000D

回答3:

你看看这个,http://shuany.javaeye.com/blog/698675