Personally, I think you should consider the following two
possible solutions if you want extensibility and the
possibility of nested structures:
a) use ASN.1. Right now, you're on the verge of reinventing
it.
b) use XML. It requires a (simple) parser, but it seems
to be useful for encoding arbitrary length strings,
nested structures, etc.
Larry
-- http://www.parc.xerox.com/masinter