Re: Endianness in PHP

From: Date: Thu, 12 Aug 2010 09:59:26 +0000
Subject: Re: Endianness in PHP
References: 1 2 3  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7470@lists.php.net to get a copy of this message
Hi, On Wed, 2010-08-11 at 22:43 -0700, "J. Adams" wrote: > >> 1) Is there a standardized way or recommended best practice for conversions > >> of ints, longs, and doubles to network byte order? > >> > > > > Usually, operating system provides functions for this. > > Look for the following functions: htonl, htons, ntohl, ntohs > > > It's my understanding that these functions aren't always available. > This link: Right that is all OS dependent. Standard C doesn't provide any such things. What we're having is a WORDS_BIGENDIAN define which is set on big endian machines and undefined on little endian machines. which we use in some places to do manual conversions: http://lxr.php.net/opengrok/search?q=&project=PHP_5_3&defs=&refs=WORDS_BIGENDIAN&path=&hist= > >> 2) Can anyone recommend a cheap way to gain access to a Big-Endian machine > >> for development and testing? > Ugh. I was rather hoping I could get access to a VPS somewhere, perhaps > through EC2 or Rackspace.com. They all provide x86 hardware as modern big endian gear is relatively expensive and not what most people expect. Sun provided a test machine though (see also private mail) while currently I can't provide accounts there. johannes

« previous php.pecl.dev (#7470) next »