Skip to content

Add 64 bit formats to pack() and unpack() #812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2014
Merged

Conversation

lt
Copy link
Contributor

@lt lt commented Sep 8, 2014

This patch adds 4 new format codes to pack() and unpack()

q   signed long long (always 64 bit, machine byte order)
Q   unsigned long long (always 64 bit, machine byte order)
J   unsigned long long (always 64 bit, big endian byte order)
P   unsigned long long (always 64 bit, little endian byte order)

These modes are only available on 64 bit platforms.

Both q and Q mimic their Perl counterparts, however Perl does not have codes for specifying the endianness. I have chosen J and P to represent the 64 bit equivalents of N and V, as these are both formats in Perl that have no real business in PHP. J is for Perls internal integer format, and P is for pointers to structures.

@rdlowrey
Copy link
Contributor

rdlowrey commented Sep 9, 2014

Ohhh sweet. I've needed this for a long time and haven't ever gotten around to implementing it myself. 👍

@lt
Copy link
Contributor Author

lt commented Oct 3, 2014

RFC accepted

@hikari-no-yume
Copy link
Contributor

On 32-bit platforms, the 64-bit codes don't exist at all under this patch. I don't think that's ideal. Could you make it produce an error that makes it obvious why they're missing? Something like Error: 64-bit unpack codes are only available on 64-bit platforms. Otherwise I think users might get confused.

@lt lt force-pushed the unpack-64 branch 2 times, most recently from 6009db7 to 96793b3 Compare October 7, 2014 13:20
@lt
Copy link
Contributor Author

lt commented Oct 9, 2014

Squashed commits for merge - error message concern was addressed

@php-pulls php-pulls merged commit 63fd969 into php:PHP-5.6 Oct 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants