I know of 3 possibilities: CR is line end (Apple), LF is line end
(nixes) and CRLF is line end (Win).
fopen() the txt. Read one char at a time. Use 3 vars: cr_found,
lf_found, crlf_found. When you encounter CR or LF you consider the
subsequent character and determine the EOL.
You can have CR true and no LF subsequent, or CR and LF or LF and no
previous CR.
Now you can read line by line and write to a new normalized file with
the desired EOL.
readline - reads a line from a txt file
Usage: nRet = readline(<nhdl>,@cBuffer [,<eol>])
Returns: 0 if eof not encountered, -1 if eof
// nHdl = handle of the file FOPENed
// cLine = buffer for line (pass for reference)
// eol = end-of-line
function readline(nHdl,cLine,eol)
local nEol:=.f.,RetVal:=0
local byte:=" ",z
if empty(eol)
eol = hb_osnewline() //hb_eol()
endif
cLine=""
do while .t.
z:=fread(nHdl,@byte,1)
if z=0
if len(cLine)=0
retval:=-1
endif
exit
endif
cLine=cLine+byte
if len(cLine)>=len(eol)
if right(cLine,len(eol))=eol
cLine=strtran(cLine,eol,"")
exit
endif
endif
enddo
return RetVal
-----
nHdlIn := fopen("suspect.txt",FO_READ)
nHdlOut := fcreate("normalized.txt", FO_WRITE)
buffer := ""
EOLIn := chr(10)
EOLOut := chr(13)+chr(10)
do while readline ( nHdl, @buffer, EolIn ) == 0
fwrite ( nHdlOut, buffer+EOLOut )
enddo
fclose ( nHdlIn )
fclose ( nHdlOut )
(UNTESTED)
HTH
Dan