我有表示表的二进制数据。
这是我使用 Python 的repr()打印时的数据:
\xff\xff\x05\x04test\x02A\x05test1@\x04\x03@@\x04\x05@0\x00\x00@\x05\x05test2\x03\x05\x05test1\x06@0\x00\x01@\x00
这是该表在专有软件中的样子。
test1
test1test1
test test1
test1
test1test2
test1
test1
test1
test1
test1
test1
test1
我猜到了其中的一些:
- 它是逐列然后逐个单元格,从左上角的单元格开始。
- 在
\x04
中\x04test
似乎是以下单词的长度(以字节我猜)。 @
意思是最后一个值
任何人都知道数据是否遵循标准或有任何如何解码的提示?
谢谢!
这是一个 python 示例:
from struct import unpack
def DecodeData(position):
print "position", position
firstChar = data[position:][:1]
size_in_bytes = unpack('B', firstChar)[0]
print "firstChar: {0}. size_in_bytes: {1}".format(repr(firstChar), size_in_bytes)
return size_in_bytes
def ReadWord(position, size_in_bytes):
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word
data = "\xff\xff\x05\x04test\x02A\x05test1@\x04\x03@@\x04\x05@0\x00\x00@\x05\x05test2\x03\x05\x05test1\x06@0\x00\x01@\x00"
position = 0
print ""
position += 1
DecodeData(position)
print "\\xff - ?"
print ""
position += 1
DecodeData(position)
print "\\x05 - ?"
print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
ReadWord(position, size_in_bytes)
print ""
position += size_in_bytes
DecodeData(position)
position += 1
DecodeData(position)
print """'2A' : could be to say that "test" has 2 empty cells before it"""
print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word
position += size_in_bytes
DecodeData(position)
print """@: mean that there's another "test1" cell"""
print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x04\\x03 - Could be that the next value is 3 cells down"
print ""
position += 1
DecodeData(position)
print ""
position += 1
print "@@ - Seems to mean 3 repetitions"
print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x04\\x05 - Could be that the next value is 5 cells down"
print ""
position += 1
DecodeData(position)
print "@ - repetition"
print ""
position += 1
DecodeData(position)
print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x00\\x00 - That could mean to move to the first cell on the next column"
print ""
position += 1
DecodeData(position)
print "@ - repetition"
print ""
position += 1
DecodeData(position)
print "\\x05 - ?"
print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word
position += size_in_bytes
print ""
DecodeData(position)
print "\\x03 - Could be to tell that the pervious word 'test2' is 3 cells down"
print ""
position += 1
DecodeData(position)
print "\\x05 - ?"
print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word
position += size_in_bytes
print ""
DecodeData(position)
print "\\x06 - Could be to tell that the pervious word 'test1' is 6 cells down"
print ""
position += 1
DecodeData(position)
print "@ - repetition"
print ""
position += 1
DecodeData(position)
print "\\0 - ?"
print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x00\\x01 - Seems to mean, next column second cell"
print ""
position += 1
DecodeData(position)
print "@ - repetition"
print ""
position += 1
DecodeData(position)
print "\\x00 - end of data or column"