|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63630 32bit signed littleendian (machine independent) support for pack() and unpack()
Submitted: 2012-11-27 22:37 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cf0hay at gmail dot com Assigned:
Status: Open Package: Strings related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cf0hay at gmail dot com
New email:
PHP Version: OS:


 [2012-11-27 22:37 UTC] cf0hay at gmail dot com
pack() and unpack() are very useful functions, but would be nice to have a machine 
independent support for signed numbers, especially signed 32-bit little endian. If 
there are code alread for this, then they only missing from the documentation.

Test script:
// Let's say, "E" would mean 32-bit signed little endian

echo unpack("E","A\xE2\x82\xAC")[1]."\n"; //PHP 5.4 syntax, would give back always -1400708543, regardless of architecture endianness (same az "l" on little endian system).

echo pack("E",-1400708543)."\n"; //would give back A€ on a UTF-8 terminal, same as "l" on a little endian system

Expected result:

Actual result:
unknown format code


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 05:01:29 2024 UTC