converting binary data
Dan Stromberg
strombrg at dcs.nac.uci.edu
Wed Apr 27 22:18:18 EDT 2005
I've written up a page about how to convert native binary data to
another platform's native binary data, as I did some fortran data
conversions for a client.
The programs and documentation are at:
http://dcs.nac.uci.edu/~strombrg/converting-binary.html
So far, the page includes a variety of programs written in C or python to
do:
1) A program for determining if your machine is big endian, little endian,
or something else
2) A program for swapping big endian to little endian, or vice versa, on
words of an arbitrary number of bytes, assuming a homogeneous size for all
items in the file
3) A pair of programs for converting a series of reals/floats to ascii and
back again (to be used in combination with ssh, rsh, &c)
4) An example program that converts binary data with variable length
records
5) A program that removes fortran record framing for big endian or little
endian, with arbitrary word size (must bew a multiple of 8 bits)
The documentation includes:
1) A taxonomy of three different kinds of conversions
2) Tips for determining record lengths
3) An admonition to reject these methods, and instead convert to a
platform-independent representation. A list of common
platform-independent representations is given.
I hope someone will find this useful.
More information about the Python-list
mailing list