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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC