php pack與unpack 摸板字符字符含義
更新時(shí)間:2009年10月29日 22:42:09 作者:
pack/unpack的摸板字符字符含義,需要的朋友可以參考下。
format 參數(shù)的可能值:
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è)填充空的字節(jié)串
A一個(gè)填充空格的字節(jié)串
b一個(gè)位串,在每個(gè)字節(jié)里位的順序都是升序
B一個(gè)位串,在每個(gè)字節(jié)里位的順序都是降序
c一個(gè)有符號(hào)char(8位整數(shù))值
C一個(gè)無(wú)符號(hào)char(8位整數(shù))值;關(guān)于Unicode參閱U
d本機(jī)格式的雙精度浮點(diǎn)數(shù)
f本機(jī)格式的單精度浮點(diǎn)數(shù)
h一個(gè)十六進(jìn)制串,低四位在前
H一個(gè)十六進(jìn)制串,高四位在前
i一個(gè)有符號(hào)整數(shù)值,本機(jī)格式
I一個(gè)無(wú)符號(hào)整數(shù)值,本機(jī)格式
l一個(gè)有符號(hào)長(zhǎng)整形,總是32位
L一個(gè)無(wú)符號(hào)長(zhǎng)整形,總是32位
n一個(gè)16位短整形,“網(wǎng)絡(luò)”字節(jié)序(大頭在前)
N一個(gè)32位短整形,“網(wǎng)絡(luò)”字節(jié)序(大頭在前)
p一個(gè)指向空結(jié)尾的字串的指針
P一個(gè)指向定長(zhǎng)字串的指針
q一個(gè)有符號(hào)四倍(64位整數(shù))值
Q一個(gè)無(wú)符號(hào)四倍(64位整數(shù))值
s一個(gè)有符號(hào)短整數(shù)值,總是16位
S一個(gè)無(wú)符號(hào)短整數(shù)值,總是16位,字節(jié)序跟機(jī)器芯片有關(guān)
u一個(gè)無(wú)編碼的字串
U一個(gè)Unicode字符數(shù)字
v一個(gè)“VAX”字節(jié)序(小頭在前)的16位短整數(shù)
V一個(gè)“VAX”字節(jié)序(小頭在前)的32位短整數(shù)
w一個(gè)BER壓縮的整數(shù)
x一個(gè)空字節(jié)(向前忽略一個(gè)字節(jié))
X備份一個(gè)字節(jié)
Z一個(gè)空結(jié)束的(和空填充的)字節(jié)串
規(guī)則:
1.每個(gè)字母后面都可以跟著一個(gè)數(shù)字,表示count(計(jì)數(shù)),如果count是一個(gè)*表示剩下的所有東西。
2.如果你提供的參數(shù)比$format要求的少,pack假設(shè)缺的都是空值。如果你提供的參數(shù)比$format要求的多,那么多余的參數(shù)被忽略。
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è)填充空的字節(jié)串
A一個(gè)填充空格的字節(jié)串
b一個(gè)位串,在每個(gè)字節(jié)里位的順序都是升序
B一個(gè)位串,在每個(gè)字節(jié)里位的順序都是降序
c一個(gè)有符號(hào)char(8位整數(shù))值
C一個(gè)無(wú)符號(hào)char(8位整數(shù))值;關(guān)于Unicode參閱U
d本機(jī)格式的雙精度浮點(diǎn)數(shù)
f本機(jī)格式的單精度浮點(diǎn)數(shù)
h一個(gè)十六進(jìn)制串,低四位在前
H一個(gè)十六進(jìn)制串,高四位在前
i一個(gè)有符號(hào)整數(shù)值,本機(jī)格式
I一個(gè)無(wú)符號(hào)整數(shù)值,本機(jī)格式
l一個(gè)有符號(hào)長(zhǎng)整形,總是32位
L一個(gè)無(wú)符號(hào)長(zhǎng)整形,總是32位
n一個(gè)16位短整形,“網(wǎng)絡(luò)”字節(jié)序(大頭在前)
N一個(gè)32位短整形,“網(wǎng)絡(luò)”字節(jié)序(大頭在前)
p一個(gè)指向空結(jié)尾的字串的指針
P一個(gè)指向定長(zhǎng)字串的指針
q一個(gè)有符號(hào)四倍(64位整數(shù))值
Q一個(gè)無(wú)符號(hào)四倍(64位整數(shù))值
s一個(gè)有符號(hào)短整數(shù)值,總是16位
S一個(gè)無(wú)符號(hào)短整數(shù)值,總是16位,字節(jié)序跟機(jī)器芯片有關(guān)
u一個(gè)無(wú)編碼的字串
U一個(gè)Unicode字符數(shù)字
v一個(gè)“VAX”字節(jié)序(小頭在前)的16位短整數(shù)
V一個(gè)“VAX”字節(jié)序(小頭在前)的32位短整數(shù)
w一個(gè)BER壓縮的整數(shù)
x一個(gè)空字節(jié)(向前忽略一個(gè)字節(jié))
X備份一個(gè)字節(jié)
Z一個(gè)空結(jié)束的(和空填充的)字節(jié)串
規(guī)則:
1.每個(gè)字母后面都可以跟著一個(gè)數(shù)字,表示count(計(jì)數(shù)),如果count是一個(gè)*表示剩下的所有東西。
2.如果你提供的參數(shù)比$format要求的少,pack假設(shè)缺的都是空值。如果你提供的參數(shù)比$format要求的多,那么多余的參數(shù)被忽略。
相關(guān)文章
PHP 刪除文件與文件夾操作 unlink()與rmdir()這兩個(gè)函數(shù)的使用
有時(shí)候我們需要用PHP來(lái)刪除文件和文件夾,PHP本來(lái)也都有函數(shù)可以實(shí)現(xiàn),下面簡(jiǎn)單記錄一下代碼,方便以后信守拈來(lái)。2011-07-07PHP實(shí)現(xiàn)求連續(xù)子數(shù)組最大和問(wèn)題2種解決方法
這篇文章主要介紹了PHP實(shí)現(xiàn)求連續(xù)子數(shù)組最大和問(wèn)題2種解決方法,涉及php針對(duì)數(shù)組的遍歷、判斷、運(yùn)算等相關(guān)操作技巧,需要的朋友可以參考下2017-12-12講解WordPress中用于獲取評(píng)論模板和搜索表單的PHP函數(shù)
這篇文章主要介紹了WordPress中用于獲取評(píng)論模板和搜索表單的PHP函數(shù),需要的朋友可以參考下2015-12-12PHP 通過(guò)Socket收發(fā)十六進(jìn)制數(shù)據(jù)的實(shí)現(xiàn)代碼
以下是對(duì)PHP中通過(guò)Socket收發(fā)十六進(jìn)制數(shù)據(jù)的實(shí)現(xiàn)代碼進(jìn)行了分析介紹。需要的朋友可以過(guò)來(lái)參考下2013-08-08