def SignedVarintEncode(value):
 result = ''
 if (value < 0):
  value += (1 << 64)
 bits = (value & 127)
 value >>= 7
 while value:
  result += HIGH_CHR_MAP[bits]
  bits = (value & 127)
  value >>= 7
 result += CHR_MAP[bits]
 return result

def SignedVarintEncode ( value ) : result = '' if ( value < 0 ) : value += ( 1 << 64 ) bits = ( value & 127 ) value >>= 7 while value : result += HIGH_CHR_MAP [ bits ] bits = ( value & 127 ) value >>= 7 result += CHR_MAP [ bits ] return result
encode a signed integer as a zigzag encoded signed integer .