ietf-smime
[Top] [All Lists]

Re: How to do UTF-8

1998-02-23 16:01:33
On Mon, 23 Feb 1998, David P. Kemp wrote:

In ASN.1 an omitted OPTIONAL variable length item has a single encoding -
absent.  In ASN.1 a value with a missing item is entirely different from
one where the length is zero.

If one is carrying a C language string (null-terminated array of
characters) in a structure with a fixed-size buffer, how does the
application distinguish between absent and zero-length?

Assuming that an ASN.1 library takes a "char *" as an argument, that
argument can be a null pointer or a pointer to "\0", thus from the
library's point of view the encoding is unambiguous.  But from the
application's point of view, it is ambiguous unless one carries around
an additional "empty" flag for each static buffer,

These two techniques that you describe here are what the OSS ASN.1 Tools
for C employs to distinguish between absent and zero-length.

or define a special
"length" value of -1 to mean absent.

This is also possible.
 
--------------------------------------------------------------------------
Bancroft Scott                                Toll Free    :1-888-OSS-ASN1
Open Systems Solutions, Inc.                  International:1-609-987-9073
baos(_at_)oss(_dot_)com                                  Tech Support 
:1-732-249-5107
http://www.oss.com                            Fax          :1-732-249-4636


<Prev in Thread] Current Thread [Next in Thread>