Re: [RFC] Add pack()/unpack() support for signed integers with specific endianness

From: Date: Thu, 18 Sep 2025 09:15:40 +0000
Subject: Re: [RFC] Add pack()/unpack() support for signed integers with specific endianness
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-128713@lists.php.net to get a copy of this message
Am 16.09.2025 um 13:45 schrieb Alexandre Daubois <alex.daubois+php@gmail.com>: > I’d like to present this new RFC. When discussing the issue, we first thought that the RFC > process wasn’t necessary. However, discussions on the PR showed that selecting new letters for > pack and unpack is more challenging than we initially thought, thus creating an RFC for this change. > > Here is the link to the RFC: > https://wiki.php.net/rfc/pack-unpack-endianness-signed-integers-support Just a little side-note: unpackToSignedInt can be implemented more easily, e.g. like function unpackToSignedInt($bytes) { return ($uint32 = unpack('V', $bytes)[1]) < 2 ** 31 ? $uint32 : $uint32 - 2 ** 32; # Use 'N' for big endian } While I undestand the wish for having all different sizes in all different endian-ness I don't think it is that big of an issue for people dealing with binary data, so I'm +-0 whether PHP really needs it. Regards, - Chris

« previous php.internals (#128713) next »