- 相關(guān)推薦
php pack與unpack 摸板字符字符含義簡(jiǎn)介
format 參數的可能值:
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一個(gè)填充空的字節串
A一個(gè)填充空格的字節串
b一個(gè)位串,在每個(gè)字節里位的順序都是升序
B一個(gè)位串,在每個(gè)字節里位的順序都是降序
c一個(gè)有符號char(8位整數)值
C一個(gè)無(wú)符號char(8位整數)值;關(guān)于Unicode參閱U
d本機格式的雙精度浮點(diǎn)數
f本機格式的單精度浮點(diǎn)數
h一個(gè)十六進(jìn)制串,低四位在前
H一個(gè)十六進(jìn)制串,高四位在前
i一個(gè)有符號整數值,本機格式
I一個(gè)無(wú)符號整數值,本機格式
l一個(gè)有符號長(cháng)整形,總是32位
L一個(gè)無(wú)符號長(cháng)整形,總是32位
n一個(gè)16位短整形,“網(wǎng)絡(luò )”字節序(大頭在前)
N一個(gè)32位短整形,“網(wǎng)絡(luò )”字節序(大頭在前)
p一個(gè)指向空結尾的字串的指針
P一個(gè)指向定長(cháng)字串的指針
q一個(gè)有符號四倍(64位整數)值
Q一個(gè)無(wú)符號四倍(64位整數)值
s一個(gè)有符號短整數值,總是16位
S一個(gè)無(wú)符號短整數值,總是16位,字節序跟機器芯片有關(guān)
u一個(gè)無(wú)編碼的字串
U一個(gè)Unicode字符數字
v一個(gè)“VAX”字節序(小頭在前)的16位短整數
V一個(gè)“VAX”字節序(小頭在前)的32位短整數
w一個(gè)BER壓縮的整數
x一個(gè)空字節(向前忽略一個(gè)字節)
X備份一個(gè)字節
Z一個(gè)空結束的(和空填充的)字節串
規則:
1.每個(gè)字母后面都可以跟著(zhù)一個(gè)數字,表示count(計數),如果count是一個(gè)*表示剩下的所有東西。
2.如果你提供的參數比$format要求的少,pack假設缺的都是空值。如果你提供的參數比$format要求的多,那么多余的參數被忽略。
【php pack與unpack 摸板字符字符含義簡(jiǎn)介】相關(guān)文章:
關(guān)于php去除字符串中空字符的常用方法09-14
php字符串處理函數大全08-21
《PHP字符串操作》收集整理08-08
Dreamweaver插入特殊字符的方法06-12
c語(yǔ)言字符數組使用方法10-14
關(guān)于php中的一個(gè)中文字符串截取函數07-15
word文字符號輸入類(lèi)技巧08-30