php.net |  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: -
Votes:1
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cf0hay at gmail dot com
New email:
PHP Version: OS:

 

 [2012-11-27 22:37 UTC] cf0hay at gmail dot com
Description:
------------
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:
----------------
-1400708543
A€


Actual result:
--------------
unknown format code

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 00:01:27 2024 UTC