end of line character

Rahul Dhesi dhesi at bsu-cs.bsu.edu
Sat Jul 8 03:28:40 AEST 1989


In article <429 at ncelvax.UUCP> cathy at ncelvax.UUCP (Cathy Benney) writes:
[how do I do newline conversions when moving files from UNIX to MS-DOS?]

UNIX uses the ASCII linefeed character as the end-of-line character
(assuming ASCII;  there are rumors [*shudder*] of an EBCDIC UNIX).
MS-DOS uses an ASCII carriage return followed by an ASCII linefeed to
terminate each line.

Converting a UNIX text file to the MS-DOS format requires the following
transformation:

      LF => CR LF

I recently posted a newline conversion program (called "flip", which
stands for "file interchange program") to alt.sources, and I have sent
the production version to comp.sources.misc for posting.  A compiled
binary will also eventually appear in comp.binaries.ibm.pc.  There are
quite a few other conversion programs floating around in the public
domain world, but here's a simple one you can write and compile
yourself *on an MS-DOS system* with one of the better C compilers:

     /* Copyright 1989 Rahul Dhesi, all rights reserved.  Noncommercial
     use permitted;  inquire about commercial use license. */
     #include <stdio.h>
     main() {int c; while ((c = getc(stdin)) != EOF) putc(c, stdout);}

It works because the stdio library does the newline conversion for
you.  Use as a filter.
-- 
Rahul Dhesi <dhesi at bsu-cs.bsu.edu>
UUCP:    ...!{iuvax,pur-ee}!bsu-cs!dhesi



More information about the Comp.unix.questions mailing list