Python equivalent of Perl's 'w' packing format -
what format should use in struct.unpack
decode data packed in perl using w
format character (as doc says 'ber compressed integer')?
i don't believe python's struct module has support format, supports encodings commonly found in c structs. ber & der encodings encountered within asn.1 encoded streams... 1 of python asn.1 modules might helpful in case (i should note not user-friendly).
if not, may have implement decoder yourself. following bit of code read off int, , return in string unpacking should pick at...
def decode_ber_int(data, offset): value = 0 while true: tmp = ord(data[offset]) value = (value<<7) | (tmp&0x7f) offset += 1 if tmp & 0x80 == 0: break return value, offset
sadly, require breaking unpack call unpack, decode_ber_int, , unpack rest.
Comments
Post a Comment