本文主要是介绍php+中英文翻译包,php 翻译pack,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
pack -将数据打包为二进制字符串
Description
描述
string pack ( string $format [, mixed $args [, mixed $... ]] )
返回 string 参数列表
mixed 说明一个参数可以接受多种不同的(但并不必须是所有的)类型。
Pack given arguments into binary string according to format .
pack 函数通过给定的参数 格式化数据 ,返回二进制字符串。
The idea for this function was taken from Perl and all formatting codes work the same as in Perl. However, there are some formatting codes that are missing such as Perl's "u" format code.
本函数的创意来源于perl语言,其所有格式代码工作原理跟perl下一致。尽管其部分格式代码没有perl语言下面的‘U’字符。
Note that the distinction between signed and unsigned values only affects the function unpack() , where as function pack() gives the same result for signed and unsigned format codes.
请注意,有符号和无符号数值的区别,只会影响到unpack函数,pack函数会给出相同的(有符号和无符号)格式码。
Also note that PHP internally stores integer values as signed values of a machine-dependent size. If you give it an unsigned integer value too large to be stored that way it is converted to a float which often yields an undesired result.
也应当注意,php内置整形数值是作为有符号的依赖机器字节的方式 储存。如果你输入的无符号整形数据过大,那么将被转化为我们所不想看到的类型float型
The format string consists of format codes followed by an optional repeater argument. The repeater argument can be either an integer value or * for repeating to the end of the input data. For a, A, h, H the repeat count specifies how many characters of one data argument are taken, for @ it is the absolute position where to put the next data, for everything else the repeat count specifies how many data arguments are consumed and packed into the resulting binary string.
formart字符串使得多重可选参数和格式码相关联。多重可选参数可以是整形数值或者‘*’, 用以重复操作直到输入数据完毕。对于 A, a, H, h 的重复次数列表,由多个字符组成的数据会被接受。对于@,描述存放下一数据的绝对位置。
Currently implemented formats are:
pack() format characters
Code
Description
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
这篇关于php+中英文翻译包,php 翻译pack的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!