I have looked through the pack code in php-4.1.2.  There appear to be no
other options other than what is documented on the php.net pack function
page.  There appears to be no way of specifying endian-ness for floats or
doubles using pack.  They are copied to the output stream using a simple

I would need more details on what you are doing to be sure, but, is the
format something you can worry about on the unpacking side?  Usually, it is
best to marshall the data in the native format of the machine doing the
marshalling, and then convert the data (if needed) on the machine you are
un-marshalling on.  This usually makes debugging a whole heck of a lot
easier.  All you will have to do is store the endian-ness of the machine you
are packing on with the data being packed.  Of course, this only works if
you are not unpacking with PHP...

The code in pack.c for the pack function is pretty dang simple.  It wouldn't
take more than an hour or so to cut and paste a few sections of code to add
the options you need.  Could be good to have in future versions of php.

Good Luck.

// Mike Eynon
// www.MikeEynon.com
// 1366 Bulb Ave.
// Santa Cruz, CA  95062
// 831.588.2388

-----Original Message-----
From: Mika Tuupola [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 20, 2002 3:08 PM
Subject: [PHP] Forcing little endian with pack("d");


        The manual page describes format string "d" as:

        d double (machine dependent size and representation).

        Is there an easy way of forcing the binary to be representated
        little endian even with hosts which are big endian (undocumented
        format string for example?).

Mika Tuupola                      http://www.appelsiini.net/~tuupola/

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to