Mail Archives: djgpp/1997/08/26/03:11:34
On Mon, 25 Aug 1997, John M. Aldrich 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...
>
> True. However, a great many programs that I have seen are capable of
> recognizing EOLs, whatever their format. For example, DOS Edit can load
> and parse Unix-formatted text files. I guess they're just designed with
> that in mind.
More, precisely, many *DOS* programs can handle both DOS- and
Unix-style EOLs. In many cases this is because the programs were
written in C, and C runtime libraries on DOS and MS-Windows always
strip CR characters from EOLs.
So, if you want a text file to be portable to Unix, you should write
it in binary mode on MS-DOS, so it doesn't have those CRs.
> But your concerns are valid, which brings up another point: is there
> such a thing as a universal format for data exchange?
This is a *very* broad issue, and I don't know enough about it, even
if I wanted to answer that here. But the short answer is YES; see
Unicode for one attempt at such portable text format.
If by ``data exchange'' you mean non-text data, then the closest thing
I know of is to write the buffer/struct byte-by-byte in binary mode.
It's painful, especially with structs, and it still leaves some
problems, such as representation of floats, though.
- Raw text -