[Gambas-user] Non-linux line ending files are seen as binary by the IDE

Benoît Minisini gambas at ...1...
Tue Feb 3 13:12:14 CET 2015


Le 03/02/2015 12:45, Rolf-Werner Eilert a écrit :
> I observed that Win7 tends to add some kind of flag byte(s) at the
> beginning of the file when it's UTF-8 (under VB).

Yes, this is one of the (many) design failures of windows.

>
> Otherwise, I have solved the problem in one of my programs that must
> write UTF-8 files for a Win (VB) and Linux (Gambas) client, by adding a
> CR+LF at the end of each line when writing in Gambas and then Trim()
> each line when reading the files. The VB client, of course, can just
> read and write as it's used to do.

The 'Line Input' instruction can deal with any end-of-line sequence 
(Linux, Mac & Windows).

See the Stream.EndOfLine property. Its value can be:

- gb.Windows: the end-of-line sequence is "\r\n".
- gb.Mac: the end-of-line sequence is "\r".
- gb.Unix: the end-of-line sequence is "\n" (*or* "\r\n" on reading).

Note that gb.Unix allows you to read both Unix and Windows format, but 
only write Unix format.

Regards,

-- 
Benoît Minisini




More information about the User mailing list