Re: How to make binary data portable?



In article <Q1Wwe.14054$pa3.837@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Martin Ambuhl <mambuhl@xxxxxxxxxxxxx> wrote:
>PengYu.UT@xxxxxxxxx wrote:
>> I write the content of a in file "data" (in Sun Machine). Then I read
>> "data" in both SunOS and linux. But the result is different. Do you
>> know how to make it binary data portable.

>Binary numeric data is inherently not portable. If you want files to be
>portable, your best bet is to write numeric data as text. Even that
>assumes that the different implementations|platforms use a common form
>of encoding text.

The "xdr" library (which is NOT part of the C standard itself) was
written to try to deal with these issues. "xdr" stands for
"external data representation". It is commonly used for
Remote Procedure Calls, so it is available for a wide variety
of systems.

I seem to recall that the xdr folk got around to extending xdr to
work with 64 bit values, but I am not sure how widely those extensions
got implemented.
--
"Who Leads?" / "The men who must... driven men, compelled men."
"Freak men."
"You're all freaks, sir. But you always have been freaks.
Life is a freak. That's its hope and glory." -- Alfred Bester, TSMD
.