Date: Tue, 26 Aug 1997 10:14:30 +0300 (IDT) From: Eli Zaretskii To: firewind cc: djgpp AT delorie DOT com Subject: Re: Writing a struct to disk In-Reply-To: <5tt2p5$o6s@dfw-ixnews5.ix.netcom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 25 Aug 1997, firewind wrote: > Cesar Scarpini Rabak wrote: > > > Text format is not _that_ highly portable! When one switches from > > environment the way the end of line is marked varies, and filters or > > converting programms may be needed... > > Unlike some fortunate people, I don't have a copy of the ANSI standard handy, > but in K&R2, chapter 7, section 1, is is said: > > "A text stream consists of a sequence of lines; each line ends with a newline > character. If the system doesn't operate that way, the library does whatever > is necessary to make it appear as if it does. For instance, the library might > convert carriage return and linefeed to newline on input and back again on > output." Correct, but not quite to the point. The problem here is that if you create a text file on DOS then move it to Unix, the programs there will have difficulties handling it. Since Unix *does* ``operate that way'' (i.e., its native text files *do* end with the newline alone), libc on Unix doesn't do any conversions, and the CRs stay. ANSI only makes the behavior consistent as long as you stay on the same platform, but it doesn't tell anything about moving files between different platforms.