On 2011-10-18 19:54:33 -0700, dormando wrote:
> What I may have mentioned was that uh... size length encoding, similar to
> what MySQL uses. So a key length of < 252 bytes would be a 1b length. a
> body length of just under 2^16 would be 3 bytes (253 as a flag + 2 bytes),
> and over would be 4 bytes (254 as a flag + 3 bytes).

You could also use BER encoding (as in perl's pack("w")):

       Its bytes represent an unsigned integer in base 128,
       most significant digit first, with as few digits as possible.  Bit
       eight (the high bit) is set on each byte except the last.

With this scheme a 1 byte length can encode a length of 127, a 2 byte
length can encode a length of 2^14-1 (16k), 3 bytes encode a length of
2^21-1 (2M) and so on ...

        hp

-- 
   _  | Peter J. Holzer    | Web 2.0 könnte man also auch übersetzen als
|_|_) | Sysadmin WSR       | "Netz der kleinen Geister".
| |   | [email protected]         | 
__/   | http://www.hjp.at/ |  -- Oliver Cromm in desd

Attachment: signature.asc
Description: Digital signature

Reply via email to