欧洲用字编码\0x20AC,其UTF8的编码字元为$URF{Euro}。
# pack and unpack the Hebrew alphabet
my $alefbet = pack( ';U*';, 0x05d0..0x05ea );
my @hebrew = unpack( ';U*';, $utf );
用於pack/unpack unicode编码
另一种Portable编码:
w A BER compressed integer. Its bytes represent an unsigned integer in base 128, most significant digit first, with as few digits as possible. Bit eight (the high bit) is set on each byte except the last.
my $berbuf = pack( ';w*';, 1, 128, 128+1, 128*128+127 );
长度与宽度(Length and Width)
字串长度(String Length)
在传送网路资料时,往往需要将资料的长度放在封包的标头处,让对方Server知道後续还有多少资料需要处理:下列例子为两个null terminated字串加上资料长度,再加上资料,得到最後要送出的资料。
Z:A null terminated (ASCIZ) string, will be null padded.
my $msg = pack( ';Z*Z*CA*';, $src, $dst, length( $sm ), $sm );
而要取出资料可以用下列方式:
( $src, $dst, $len, $sm ) = unpack( ';Z*Z*CA*';, $msg );