fork download
  1. def encode7bit(value):
  2. temp = value
  3. bytes = ""
  4. while temp >= 128:
  5. bytes += chr(0x000000FF & (temp | 0x80))
  6. temp >>= 7
  7. bytes += chr(temp)
  8. return bytes
  9.  
  10. def encodeVLQ(value):
  11. o = [ chr(value & 0x7f) ]
  12. value >>= 7
  13. while value > 0:
  14. o.insert(0, chr(0x000000FF & (value | 0x80)))
  15. value >>= 7
  16. return ''.join(o)
  17.  
  18. number = 138
  19. print " VLQ: " + encode7bit(number).encode("hex")
  20. print "7bit: " + encodeVLQ(number).encode("hex")
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
 VLQ: 8a01
7bit: 810a