---------- Forwarded message ---------
From: John Cowan <xxxxxx@ccil.org>
Date: Fri, Sep 27, 2019 at 12:39 PM
Subject: Re: Length bytes and lookahead in ASN.1
To: <xxxxxx@ancell-ent.com>




On Fri, Sep 27, 2019 at 11:26 AM <xxxxxx@ancell-ent.com> wrote:

I'm assuming these lengths are purely local in scope, there's nothing that says "the complete thing I'm writing is X long, and here's part 1, part 2, etc."?

No, that's exactly what it says.  The translation of (8 "fx" ()) is:

E0 (list type) 09 (length in bytes)
   02 (integer type) 01 (length of integer in bytes) 08 (integer data)
   0C (UTF-8 type) 02 (length of string in bytes) 66 78 (UTF-8 data)
   E0 (list type) 00 (length of list in bytes

And that's it.  Byte lengths > 127 are encoded specially in 2 or more bytes.

That design allows you to efficiently skip over objects you don't want to convert to internal form, not so much because they are understood but uninteresting, but because they are not understood at all.


John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
I am he that buries his friends alive and drowns them and draws them
alive again from the water. I came from the end of a bag, but no bag
went over me.  I am the friend of bears and the guest of eagles. I am
Ringwinner and Luckwearer; and I am Barrel-rider.  --Bilbo to Smaug