Re: unpack question

From: Date: Fri, 05 Dec 2003 07:37:34 +0000
Subject: Re: unpack question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171954@lists.php.net to get a copy of this message
* Thus wrote John J Foerch (jjfoerch@earthlink.net): > Hi, > How do I unpack uint32's? I'm using the format character "L" and > numbers greater than 2^31 come back as signed integers instead. This seems > like a bug. I suppose it is a bug. It seems that all unsigned unpacks dont honor this, as the documentation on unpack does note. I did, however, write a patch that will enable the returning of unsigned values. It still needs approval and is currently only for the cvs version of php: http://zirzow.dyndns.org/patches/pack.patch A work around on this is you'll have to use s/printf() to obtain the correct unsigned value: $array = unpack('Llongvalue', -1); printf("%lu", $array['longvalue']); Curt -- If eval() is the answer, you're almost certainly asking the wrong question. -- Rasmus Lerdorf, BDFL of PHP

« previous php.general (#171954) next »