#33649 [Bgs]: unpack returns strange values
| From: | derick@php.net | Date: | Mon, 11 Jul 2005 20:59:13 +0000 |
| Subject: | #33649 [Bgs]: unpack returns strange values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81692@lists.php.net to get a copy of this message | ||
ID: 33649
Updated by: derick@php.net
Reported By: raduc at 2software dot ro
Status: Bogus
Bug Type: *Programming Data Structures
Operating System: Linux
PHP Version: 4.3.10
New Comment:
See at http://no.php.net/manual/en/function.pack.php:
S unsigned short (always 16 bit, machine byte order)
n unsigned short (always 16 bit, big endian byte order)
v unsigned short (always 16 bit, little endian byte order)
You need either n or v...
Previous Comments:
------------------------------------------------------------------------
[2005-07-11 22:57:38] derick@php.net
Doesn't seem to be a bug, the difference is endianness:
33024 in hex = 0x8100
129 in hex = 0x0081
14848 in hex = 0x3A00
58 in hex = 0x003A
------------------------------------------------------------------------
[2005-07-11 22:57:31] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2005-07-11 22:52:47] raduc at 2software dot ro
Description:
------------
Hi,
I have a really strange behaviour with unpack() function and i didn't
found any bug / issue like this one.
The result of unpack() is diff. on a spcific server (my client's new
hosting company).
I tested the script on Win and Linux and everything works fine, with
the same .dbf file (the file is not corrupted).
Please help.
Many thanks,
Radu
Reproduce code:
---------------
$data = fread ($fp, 32) or die ("Could not read data from file
<i>$file</i>");
$header_format = 'H2id/' . 'CYear/' . 'CMonth/' . 'CDay/' .
'L# of
Records/' . 'SHeader Size/' . 'SRecord Size';
$header = unpack ($header_format, $data);
Expected result:
----------------
Array ( [id] => 03 [Year] => 105 [Month] => 7 [Day] => 2 [# of Records]
=> 2713 [Header Size] => 129 [Record Size] => 58 )
Actual result:
--------------
Array ( [id] => 03 [Year] => 105 [Month] => 7 [Day] => 2 [# of Records]
=> 2713 [Header Size] => 33024 [Record Size] => 14848 )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33649&edit=1