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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
47 - 7 = ?
Subscribe to this entry?

 
 [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: Thu Mar 28 12:01:27 2024 UTC