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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -