I have binary data representing a table.
Here's the data when I print it with Python's repr():
\xff\xff\x05\x04test\x02A\x05test1@\x04\x03@@\x04\x05@0\x00\x00@\x05\x05test2\x03\x05\x05test1\x06@0\x00\x01@\x00
Here's what the table looks like in the proprietary software.
test1
test1test1
test test1
test1
test1test2
test1
test1
test1
test1
test1
test1
test1
I was able to guess some of it:
- It's column by column then cell by cell, starting at the top left cell.
- The
\x04
in\x04test
seems to be the length (in bytes I guess) of the following word. @
mean the last value
Anyone knows if the data is following a standard or have any tips how to decode it?
Thanks!
Here's an example with 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"
repr
function, assuming this is registered the normal way it is in C extension modules.import
in Python ;)