[Gambas-user] Question on preserving Windows EOL

Willy@...3475... willy at ...3474...
Sun May 17 16:18:47 CEST 2015


Hi All,

I've been struggling with something I would like to implement.

A user asked me if it would be possible to preserve Windows EOL (CRLF)
for files originating from Windows, but opened and modified in gbEdit
(Gambas written texteditor).

What happens now is that, if I add a few new lines to a windows
originated text file, the new lines will be saved with a linux EOL (LF).
The lines already having the Windows EOL (CRLF) are preserved.

gbEdit makes use of a Editor control. Saving the contents is now done
with a simple:

File.Save($sPathFileLoaded, editMain.Text)

Where $sPathFileLoaded is the full path and name of the file
AND
editMain.Text is the name of the Editor control holding the content.

Upon opening a file gbEdit determines the EOL and returns either:
CRLF for Windows EOL
LF for Unix EOL
CR for Classic Apple Mac EOL

So I have all in place to determine when Windows EOL needs to be used
upon saving.

What I need is that new lines added, to a file already using Windows
EOL, have to be saved with Windows EOL as well.

I imagine I could save the file as a stream, making sure the proper EOL
is added, but was wondering if there might be any easier way in Gambas
that can do the job (as somehow that often turns out to be the case).

Any suggestions?


-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org








More information about the User mailing list