From: "Deepak Shenoy" Subject: Re: UNIX text -> DOS text Date: 04 May 1999 00:00:00 GMT Message-ID: <7gm10f$6496@forums.borland.com> References: <7glo9a$6474@forums.borland.com> <7glslt$65f4@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.delphi.objectpascal > If someone has written code that uses this kind of buffer technique , I > would love to see the code. > This kind of question has popped up repeatedly on this list - and with > increasing use of linux and unix it would be nice to have the fastest > solution well discussed and readily available. I'm not sure this is the fastest solution , but here goes: procedure TextToDOS( szSourceFile, szDestFile : string ); var inStream, outStream : TFileStream; szBuf : string; iRead : integer; begin inStream := TFileStream.Create( szSourceFile, fmOpenRead ); outStream := TFileStream.Create( szDestFile, fmcreate); iRead := 1; try while iRead <> 0 do begin SetLength( szBuf, BUF_SIZE); iRead := inStream.Read( Pointer(szBuf)^, BUF_SIZE); if iRead < BUF_SIZE then iRead := 0; szBuf := StringReplace( szBuf, #$A, #$D#$A, [rfReplaceAll, rfIgnoreCase]); outStream.Write( Pointer(szBuf)^, Length(szBuf)); end; finally InStream.Free; outStream.Free; end; end; Well, this assumes the text is DEFINITELY in UNIX format (CRs only, no CRLFs) ...pretty simple to find that out...look for a CRLF anywhere. Deepak Shenoy http://www.agnisoft.com