Character meanings of php pack and unpack

Source: Internet
Author: User
Tags unpack

Possible values of the format parameter:
A-NUL-padded string
A-SPACE-padded string
H-Hex string, low nibble first
H-Hex string, high nibble first
C-signed char
C-unsigned char
S-signed short (always 16 bit, machine byte order)
S-unsigned short (always 16 bit, machine byte order)
N-unsigned short (always 16 bit, big endian byte order)
V-unsigned short (always 16 bit, little endian byte order)
I-signed integer (machine dependent size and byte order)
I-unsigned integer (machine dependent size and byte order)
L-signed long (always 32 bit, machine byte order)
L-unsigned long (always 32 bit, machine byte order)
N-unsigned long (always 32 bit, big endian byte order)
V-unsigned long (always 32 bit, little endian byte order)
F-float (machine dependent size and representation)
D-double (machine dependent size and representation)
X-NUL byte
X-Back up one byte
@-NUL-fill to absolute position
A is a Null Byte string.
A is A byte string filled with spaces.
B is a single-byte string in ascending order.
B is a single-byte string. the bits in each byte are sorted in descending order.
C is a signed char (8-digit integer) value.
C is an unsigned char (8-digit integer) value. For Unicode, see U
D. double-precision floating point number in local format
F single-precision floating point number in local format
H: A hexadecimal string with four lower digits in front
H: A hexadecimal string with four digits in front
I a signed integer in the local format
I an unsigned integer in the local format
L a signed long integer, always 32-bit
L an unsigned long integer, always 32-bit
N a 16-bit short integer, "network" in byte order (front of the big head)
N a 32-bit short integer, "network" in byte order (front of the big head)
P a pointer to a null string
P a pointer to a fixed-length string
Q: A signed value of four times (64-bit integer)
Q: an unsigned four times (64-bit integer) Value
S a signed short integer value, always 16 bits
S is an unsigned short integer value, which is always 16 bits. The byte order is related to the machine chip.
U a non-encoded string
U a Unicode Character number
Va 16-bit short integer in the byte order of "VAX" (before the Small Header)
Vone is a 32-bit short integer in the byte order of "VAX" (before the Small Header ).
W: an integer compressed by a BER
X is an empty byte (ignore one byte forward)
X back up one byte
Z: An empty ending (and an empty-filled) byte string
Rules:
1. Each letter can be followed by a number, indicating count. If count is a *, it indicates all the remaining items.
2. If you provide fewer parameters than $ format, pack assumes that all parameters are missing are null values. If you provide more parameters than $ format, extra parameters are ignored.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.