[comp.unix.questions] end of line character

cathy@ncelvax.UUCP (Cathy Benney) (07/07/89)

Hello.  I am developing procedures to transfer files via tape from our 
VAX 11/730 to a COMPAQ PC which has a Qualstar tape drive attatched. 
I am running UNIX 4.3BSD, and I am downloading the files with both
the "tar" and the "dd" commands.  Qualstar has software which allows 
me to upload the files onto pc- and it works well as long as I am
transferring binary files.  Unfortunately, the UNIX-DOS transfer is
encountering problems with text files that I have created with "vi".
On the dos side, it reads the UNIX end-of-line character as just a
new line, without the carrige return.  Thus, whereas the UNIX file
might look like this:
		Mary had a little lamb.
		Its fleece was white as snow.
		And everywhere that Mary went,
		The lamb was sure to go.

The dos version makes the text look like this:

	Mary had a little lamb.
				Its fleece was white as snow.
							      And everywhere that Mary went, 
	     The lamb was sure to go.
-------------------------------------------------
Something like that.  It sees the new line, but not the carrige return.

Has anyone out there been able to fix this problem?  We use mcp for
transfer of individual files from unix to pc via sytek, but the tape
procedure would be very helpful in transferring large files or entire 
directories.  What is the UNIX end-of-line character?  I can simulate
end-of-line by physically inserting ^L^M at the end of every line of text- 
that will be recognized on both the UNIX and DOS sides.  What I'd really 
like to do, tho, is write a little C program or maybe something in sed that 
will find every occurrence of the "eol" and replace it with ^L^M.

If anyone has any insight into this, I'd appreciate it.
Thank You.  

dhesi@bsu-cs.bsu.edu (Rahul Dhesi) (07/08/89)

In article <429@ncelvax.UUCP> cathy@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@bsu-cs.bsu.edu>
UUCP:    ...!{iuvax,pur-ee}!bsu-cs!dhesi