[GAP] LF to CR-LF
Daniel Lewandowski
daniellewandowski at tlen.pl
Mon Aug 28 15:32:35 CEST 2006
Dnia 28-08-2006, pon o godzinie 08:54 -0400, Robert Dewar napisał(a):
> Because by default Text_IO files are opened in the mode where the
> OS changes any occurrence of LF to CR/LF, which seems to be the best
> default choice. If you look at your program:
>
> procedure S is
> File : File_Type;
> Line : constant String := "ala ma" & Latin_1.Lf & " kota";
> begin
> Create (File => File, Name => "out.txt", Mode => Out_File);
> Put_Line (File => File, Item => Line);
> Close (File => File);
> end S;
>
> On a Unix system this would create a standard format text file with
> two lines. With the default interpretation we have chosen, this
> program will have the same effect in a DOS type environment.
>
> If we chose to output the LF on its own, the resulting file would not be
> a standard format text file.
I understand this. But the real problem is in case the string contains
CR & LF. Text_IO sees LF and inserts CR before it. As a result I have CR
& CR & LF in a "standard" text file. Some applications really don't like
this line terminator.
> If you want the effect of LF's without CR's, you could get this by
> manually opening the C stream with appropriate options, but then the
> marker at the end of all lines would be simply LF.
Not so elegant but I will try this. I can manually add CR at the end of
a string.
Regards,
Daniel Lewandowski
More information about the GAP
mailing list