D. J. Bernstein
TCP/IP
ucspi-tcp

The addcr and delcr programs

addcr inserts a CR (\015) before each LF (\012), i.e., at the end of each line of input. It does not insert a CR at the end of a partial final line.

delcr removes a CR at the end of each line of input, if a CR is present. It does not remove a CR at the end of a partial final line.

Some unix2dos and dos2unix programs have trouble with long lines and nulls. addcr and delcr have no trouble with long lines and nulls.