Ruby implementation of the recursive length prefix encoding