1.ord函数
$num = ord($char); #把字符转换为整数
2.chr函数
$char = chr($num); #把整数转换为字符
3.printf函数
printf("Number %d is character %c\n", 101, 101); #格式化输出一个整数和字符.
printf "%vd\n", "fac\x{0327}ade";
102.97.99.807.97.100.101
printf "%vx\n", "fac\x{0327}ade";
66.61.63.327.61.64.65
4.unpack函数(C*把一个字符串转换为byte数组)(U*是指定的unicode)
@ascii_character_numbers = unpack("C*", "sample");
print "@ascii_character_numbers\n";
115 97 109 112 108 101
5.pack函数(C*把一个byte数组转换为一个字符串)
$word = pack("C*", @ascii_character_numbers);
$word = pack("C*", 115, 97, 109, 112, 108, 101); # same
print "$word\n";
sample