Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129056 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 691321A00BC for ; Mon, 3 Nov 2025 17:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762191224; bh=DZns12LyzxKc4fn9TsL2Voqamn+gld+RYlJ1BDsSdHE=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=MqbSOUKvXWrxlUynyy1TAJ9ySySazO3N5ag+nNyGa47iioABHFMJTowB/dwkie9h2 KXmM8UQAuY6OOvRRyJ9suafLFbQhIpyFpsIdJt8Kfo3UcxcLyrcoqSpDgNhcEq75Sn mFqF4uY+fZPoJLzdplujyjt9QbI2AFpinjsgaP7TUTqCuQ0r3tcPIYgZ4dPix0kcSI jLClss3Tfxf8s2KlTFWUuNPPxUYjs/041P9DV+q1N9sQmrcTyE8wHkwpvPnXI3FhNx ByskH5929pSsQVkVE95dgHRG03bWZM2EBJ3f/p4z7gTJe+KR3PdcHaqS4n667786Tb jYqDf7oZY/Amg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3CB081801DE for ; Mon, 3 Nov 2025 17:33:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 3 Nov 2025 17:33:42 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id F2A431D003E3; Mon, 3 Nov 2025 12:33:36 -0500 (EST) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-12.internal (MEProxy); Mon, 03 Nov 2025 12:33:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1762191216; x= 1762277616; bh=7T1/L2oX2yyya/CMeCzcQOOLCB4mfaWDuw3OJN8u/2w=; b=Y BnfMIZGnBiJ/LUL+zuv28174z7I86ju1gRr/J/OFA7ROOpk+m8lELc2f5DwoQYYJ 6xqus/eEE6tLgNx0CQq5+T5d5aDnX6xKOGh6Pilg4q9hJfUJFptaJQhAtJNgy/dP Jh1UhH7+DAAZAPWvvRXRahNyYwGIc/D+fXmG6Mh9iui+OZmLoJb5KBZ9JY/xi1Nb 5FOX7JuecPKDqDHnxsuHSNc9jNtoKfS3aX12CxYCoWsd68/E8V29MIB3VDkA9wQm O4ZjOQkggsTX1/n+2zXHoPmg2wcHGfpLvMf6UB7WJEywvEAx1bRTBvg/K/wryovA s6cP3J9alVL3uZRJPD/QQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1762191216; x=1762277616; bh=7T1/L2oX2yyya/CMeCzcQOOLCB4mfaWDuw3 OJN8u/2w=; b=xiLOVIJTHFNDmnWI1i0RFreqinAz4ZOGaQ81fUr9RbCOeM96spB /Vug+nldKGsmpeHZ/kS7ofoKrNxHXaF/o/oJMVK44vstVVD5tRbVifkVuilD0ZUg H9IfNV8h5Hd+u8zCkt7xlb1nf4C35qLSO+ZInGY8lSGWLVA7ZqyLyTAkXUc5f8Sq 5EQJOl9WEX3jYP6bySU7gBmarpCn39aPYWrCXasdhHpWwe8WmGVxqKIqig9Y/3fZ KngJvUiMwf6KNplEuXHWqqgPmVhb2H8mz1OTbHfLeABg68itniaEAsOpUj2PWapA RCezciSQYlAqZZU5fAF0kaZcb49sHcRs6KQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddujeekjeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfn rghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtth gvrhhnpeetieeigeejffffhefgiedtjeffgfefuddugfefffelhfekhfegvdfgudejffdu tdenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvshdp nhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepthhimh essggrshhtvghlshhtuhdrsggvpdhrtghpthhtoheprghlvgigrdgurghusghoihhsodhp hhhpsehgmhgrihhlrdgtohhmpdhrtghpthhtohepihhnthgvrhhnrghlshesghhpsgdrmh hovgdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id BCD751820054; Mon, 3 Nov 2025 12:33:35 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AypYfSb8ssWo Date: Mon, 03 Nov 2025 18:33:15 +0100 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , "Gina P. Banyard" Cc: "Alexandre Daubois" , "PHP internals list" Message-ID: <4ecce462-6d20-4958-931d-b160e79752c4@app.fastmail.com> In-Reply-To: References: <86c27cd68c8ba8056d832a845eb15dcd@bastelstu.be> Subject: Re: [PHP-DEV] Re: [RFC] Add pack()/unpack() support for signed integers with specific endianness Content-Type: multipart/alternative; boundary=c7783a3641a24f14bbcb51175bdca748 From: rob@bottled.codes ("Rob Landers") --c7783a3641a24f14bbcb51175bdca748 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Nov 3, 2025, at 17:09, Tim D=C3=BCsterhus wrote: > Hi >=20 > Am 2025-11-03 15:51, schrieb Gina P. Banyard: > > While the < > syntax to "force" the endianess of a sequence specifie= r=20 > > is nice. > > But if this requires rewriting the whole parser as this RFC implies,=20 > > then you are asking someone to commit to a larger amount of work tha= n=20 > > they signed up, which is considered bad RFC etiquette. [1] >=20 > I disagree with that claim in the RFC and to put my money where my mou= th=20 > is, I have spent the 15 minutes of writing the necessary patch for the=20 > pack() function. It is attached to this email and also available as th= is=20 > gist: https://gist.github.com/TimWolla/d8bca56a6507226e684827d2a7b4482= 9.=20 > Given the time spent, I've only given it light testing, but it passes=20 > all existing `pack()` tests and returns the correct output for: >=20 > =20 > var_dump(bin2hex(pack('s<2s>2', 258, -2, 258, -2))); > var_dump(bin2hex(pack('a>', 258))); >=20 > Using `perl -e "print pack('s<2s>2', 258, -2, 258, -2)" |xxd` as a=20 > comparison. I have not created the patch for `unpack()`, but I believe=20 > this is already sufficient demonstration that =E2=80=9Crewriting the w= hole=20 > parser=E2=80=9D is not necessary at all. >=20 > Best regards > Tim D=C3=BCsterhus >=20 > *Attachments:* > =E2=80=A2 0001-pack-Support-endian-specifier.patch Please don=E2=80=99t do this.=20 For those of us using pack()/unpack(), I don=E2=80=99t really care how m= uch like or unlike Perl it is, and having to switch strings based on php= version because someone wanted it like Perl sounds like a special kind = of hell. It=E2=80=99s already tricky enough to get pack/unpack right whe= n dealing with binary data and having to do it twice plus maintain two d= ifferent versions of the same string=E2=80=A6 no thank you. It=E2=80=99s also used subtly in all kinds of unexpected places (totp ca= lculations, encryption polyfills, etc). This kind of change would almost= necessitate a major version bump of php.=20 =E2=80=94 Rob --c7783a3641a24f14bbcb51175bdca748 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Mon, Nov 3, 2025, at 17:09, Tim D=C3=BCsterhus wrot= e:
Hi

Am 2025-11-03 15:51, schrieb Gina P. Banyard:
= > While the < > syntax to "force" the endianess of a sequence s= pecifier 
> is nice.
> But if this requir= es rewriting the whole parser as this RFC implies, 
> = then you are asking someone to commit to a larger amount of work than&nb= sp;
> they signed up, which is considered bad RFC etiquette= . [1]

I disagree with that claim in the RFC and= to put my money where my mouth 
is, I have spent the 15 = minutes of writing the necessary patch for the 
pack() fu= nction. It is attached to this email and also available as this 
Given the time spent, I've only = given it light testing, but it passes 
all existing `pack= ()` tests and returns the correct output for:

&= nbsp;    <?php

  &n= bsp;  var_dump(bin2hex(pack('s<2s>2', 258, -2, 258, -2)));
     var_dump(bin2hex(pack('a>', 258)));<= /div>

Using `perl -e "print pack('s<2s>2', 258,= -2, 258, -2)" |xxd` as a 
comparison. I have not created= the patch for `unpack()`, but I believe 
this is already= sufficient demonstration that =E2=80=9Crewriting the whole 
<= div>parser=E2=80=9D is not necessary at all.

Be= st regards
Tim D=C3=BCsterhus

Atta= chments:
  • 0001-pack-Support-endian-specifier.patch
  • <= /ul>

Please don=E2=80=99t do this.

For those of us using pack()/unpack(), I don=E2=80=99= t really care how much like or unlike Perl it is, and having to switch s= trings based on php version because someone wanted it like Perl sounds l= ike a special kind of hell. It=E2=80=99s already tricky enough to get pa= ck/unpack right when dealing with binary data and having to do it twice = plus maintain two different versions of the same string=E2=80=A6 no than= k you.

It=E2=80=99s also used subtly in all kin= ds of unexpected places (totp calculations, encryption polyfills, etc). = This kind of change would almost necessitate a major version bump of php= . 

=E2=80=94 Rob
= --c7783a3641a24f14bbcb51175bdca748--