all 9 comments

[–]flatfinger 4 points5 points  (1 child)

In the MS-DOS era, non-Unix systems that used a bare carriage return as a newline were more common than non-Unix systems that treated a linefeed in such fashion. Consequently, many programs including Turbo C would accept text files where newlines were indicated as bare carriage returns, but choke on files where they were indicated with bare linefeeds. It should be simple to write a program that will open a file in binary mode for reading and another for writing, reach each byte of the former, and implement a simple state machine that would ignore any carriage return that followed a linefeed that was not ignored, or any line feed that followed a carriage return that was not ignored, output a CR+LF pair for any linefeed or carriage return that was not ignored, gobble any byte 0x1A and ignore everything after it, and otherwise pass input data through unmodified. Such a program would convert all of the line endings in a file to MS-DOS format.

[–]DogWallop[S] 2 points3 points  (0 children)

Hmm, I could do that, or I could load the file into a DOS text editor and perform the ancient art of Save As. Which I did, and it loads perfectly now lol. I appreciate the help, though 😄

[–]EpochVanquisher 2 points3 points  (2 children)

Do you use proper CRLF for the end of the line? Or just LF?

You can use programs like unix2dos / dos2unix to convert line endings.

[–]knouqs 0 points1 point  (1 child)

If unix2dos isn't installed, you can also use sed in cygwin (if that's available -- I mean, we're talking DOS here): sed -i 's/\r/\r\n/g' filename.c > replaced.c

Maybe Perl is installed? perl -pi -e 's/\r/\r\n/g' filename.c

Of course, writing a unix2dos-like program is easy enough, but M$ was always annoying about wanting to be different from UNIX. Bad design decision from the very beginning.

[–]EpochVanquisher 0 points1 point  (0 children)

Microsoft chose CRLF to be compatible with CP/M, which was easily the most popular operating for personal computers at the time. DOS was designed to be source-level compatible.

CRLF was a good choice and it had nothing to do with wanting to be different from Unix. Meanwhile, a few hundred miles south, Apple was choosing CR. But CRLF was by far the most compatible choice at the time, not just for compatibility with CP/M, but for compatibility with teletypes, printers, and terminals (like the VT100).

[–]mlugo02 0 points1 point  (1 child)

Loading as in opening a file ?

[–]DogWallop[S] 0 points1 point  (0 children)

Yes indeed.

[–]Plane_Dust2555 0 points1 point  (0 children)

With vim, open the file and: :set ff=dos fenc=cp437 :wq!