https://bugfix-66.com/2c1df73cab89ec76d6fa10caf8a27c1fbe4d16...
and the decoder:
https://bugfix-66.com/1efa93a5eb0cc12b3de7cd1dab8e471a2cc95e...
The common varint, which you see in applications everywhere (e.g., git), is just base-128 version of the above general scheme!
But base-32 or base-8 or base-64 varints can be a big win for some purposes. Remove the zig-zag encoding if negative integers don't occur.