Do line endings differ between Windows and Linux? [closed]

From Wikipedia:

  • LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS
    X
    , FreeBSD, etc.), BeOS, Amiga, RISC
    OS, and others
  • CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M,
    MP/M, DOS, OS/2, Microsoft Windows,
    Symbian OS
  • CR: Commodore machines, Apple II family, Mac OS up to version 9 and
    OS-9

I translate this into these line endings in general:

  • Windows: '\r\n'
  • Mac (OS 9-): '\r'
  • Mac (OS 10+): '\n'
  • Unix/Linux: '\n'

You need to make your scanner/parser handle the unix version, too.

Leave a Comment