On Mon, 2011-02-14 at 13:03 -0500, Verde Denim wrote: > On Mon, Feb 14, 2011 at 12:46 PM, MRAB <pyt...@mrabarnett.plus.com> > wrote: > On 14/02/2011 17:10, Verde Denim wrote: > All > I'm a bit new to py coding and need to setup some code to > encode/decode > base 128. > Anyone here have some info they can point me to do get thdone? I've > been looking around on the web for a few days and can't seetlay my > hands on anything definitive. > Thanks in advance for your help. > http://en.wikipedia.org/wiki/LEB128
> Thanks for the reply. The link you sent will (hopefully) give me a > starting point. Do you know if there are particular implementations of > base 128 encoding that differ from LEB? The ULEB128Adapter class @ < https://bitbucket.org/cmcqueen1975/pythondwarf/src/f2ffeabfa2a6/dwarf32.py> ??? class ULEB128Adapter(Adapter): """ Adapter for DWARF unsigned LEB128. """ def _encode(self, obj, context): obj2 = [] value = int(obj) while True: byte = value & 0x7F value >>= 7 if value != 0: byte = byte | 0x80 obj2.append(chr(byte)) if value == 0: break return obj2 def _decode(self, obj, context): value = 0 for b in reversed(obj): value = value * 128 + (ord(b) & 0x7F) return value -- http://mail.python.org/mailman/listinfo/python-list