www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/26/03:11:34

Date: Tue, 26 Aug 1997 10:09:31 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "John M. Aldrich" <fighteer AT cs DOT com>
cc: Cesar Scarpini Rabak <csrabak AT dce03 DOT ipt DOT br>, djgpp AT delorie DOT com
Subject: Re: Writing a struct to disk
In-Reply-To: <3401CC3F.3C1A@cs.com>
Message-ID: <Pine.SUN.3.91.970826100900.5294F-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019