You shouldn't use any of those garbage functions. Just ignore \0 entirely, manage your lengths, and use memcpy.
But you could do something utf-8 inspired I suppose where some bit pattern in the first byte of the length tells you how many bytes are actually used for the length.
This is a totally good idea, but was considered to be too much of a pain to use at the time.