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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Dec 21 17:01:58 2024 UTC