linwin

This is a simple text conversion utility that converts text files created on a Linux system to a win32 format (and vice versa). The main problem is that Windows uses a carriage return followed by a newline (\r\n) whereas Unix based systems just use a newline. This utility replaces all the \n with \r\n for proper formatting on a win32 system.

Also, I specifically write text files in the vi editor, which is set up to put a newline at the end of each line of text. (I have a line of text set up to be 80 chars.) However, unlike the fixed-width chars in Unix, in the windows environment there are variable-sized fonts which screws up the formatting, and makes it appear as if there are random newlines throughout the text. This utility will replace all of the newlines at the end of lines with a space to keep the flow of the text. The user can pass in a variable where if the number of chars on a line is less than that, then the utility will include the newline. This is for cases where you might have something like:
Sincerely,
Tom M
Obviously, you want the newline after "Sincerely," The default number is 67, which means any line with less than 67 chars will keep the newline appended to it. By setting the variable to 0, all newlines will be removed. By setting it to 80, no newlines will be removed.

The program is run as follows:
Usage: linwin [OPTION]... INPUTFILE OUTPUTFILE
Convert a text file from Linux formatting to Win32, or vice versa.
 -n num                    The maximum number of chars where a '\n' is copied
                             to the output file.
 -l                        Convert text file from win32 to Linux formatting
                             (remove '\r's).
 -h, --help                Print help (this screen).
 
For example:
[tommut@scoobs docs]$ linwin -n 75 storyOutline.txt
This will format the file storyOutline.txt for windows use and remove all newlines of lines over 75 chars long.
View the source : linwin.c