php+中英文翻译包,php 翻译pack

PHP的pack()函数用于将数据按照指定格式转换成二进制字符串。该函数灵感来源于Perl,提供了如A、N、C等格式代码,支持整数、浮点数等多种类型的数据打包。需要注意的是,有符号和无符号数值在打包时表现相同,但在unpack()时会有区别。此外,PHP内部存储整数的方式可能因机器字节序而异,过大的无符号整数会被转化为float。
摘要由CSDN通过智能技术生成

pack -将数据打包为二进制字符串

916a9944deebb0ef88fb512938a12340.gif 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值