SMS 消息是 7 位 ASCII 打包成一个 8 位流。您可以在规范 (pdf) 的第 6.1 节中阅读有关格式的信息
在您的示例中,“C8 34”等于:
Hex Binary
C8 11001000
34 00110100
当使用文档中的规则进行拆分时,它看起来像这样:
Hex Binary
48 1001000 most significant bit is moved to next char's least significant bit
69 1101001
00 00
要解析这个,你想做这样的事情:
bytes = (0xC8, 0xF7, 0x1D, 0x14, 0x96, 0x97, 0x41, 0xF9, 0x77, 0xFD, 0x07)
number = 0
bitcount = 0
output = ''
for byte in bytes:
# add data on to the end
number = number + (byte << bitcount)
# increase the counter
bitcount = bitcount + 1
# output the first 7 bits
output = output + '%c' % (number % 128)
# then throw them away
number = number >> 7
# every 7th letter you have an extra one in the buffer
if bitcount == 7:
output = output + '%c' % (number)
bitcount = 0
number = 0
print output
不是最优雅的解决方案,但它应该可以工作。这是一个可能也有帮助的 JavaScript 实现。