TOC PREV NEXT INDEX


Character String Types



As of version 5.0 and above, character string types are now built into the compiler. Previous versions used compiled definitions based on the OCTET STRING base type to model these types. All 8-bit character character-string types now are derived from the C character pointer (char*) base type. This pointer is used to hold a null-terminated C string for encoding/decoding. For encoding, the string can either be static (i.e., a string literal or address of a static buffer) or dynamic. The decoder allocates dynamic memory from within its context to hold the memory for the string. This memory is released when the rtMemFree function is called.

The useful character string types in ASN.1 are as follows:

UTF8String      ::= [UNIVERSAL 12] IMPLICIT OCTET STRING
 
NumericString   ::= [UNIVERSAL 18] IMPLICIT IA5String
 
PrintableString ::= [UNIVERSAL 19] IMPLICIT IA5String
 
T61String       ::= [UNIVERSAL 20] IMPLICIT OCTET STRING
 
VideotexString  ::= [UNIVERSAL 21] IMPLICIT OCTET STRING
 
IA5String       ::= [UNIVERSAL 22] IMPLICIT OCTET STRING
 
UTCTime         ::= [UNIVERSAL 23] IMPLICIT GeneralizedTime
 
GeneralizedTime ::= [UNIVERSAL 24] IMPLICIT IA5String
 
GraphicString   ::= [UNIVERSAL 25] IMPLICIT OCTET STRING
 
VisibleString   ::= [UNIVERSAL 26] IMPLICIT OCTET STRING
 
GeneralString   ::= [UNIVERSAL 27] IMPLICIT OCTET STRING
 
UniversalString ::= [UNIVERSAL 28] IMPLICIT OCTET STRING
 
BMPString       ::= [UNIVERSAL 30] IMPLICIT OCTET STRING
 
ObjectDescriptor ::= [UNIVERSAL 7] IMPLICIT GraphicString
 

Of these, all are represented by char* pointers except for the BMPString and UniversalString types. The BMPString is a 16-bit character string for which the following structure is used:

typedef struct {
 
   ASN1UINT       nchars;
 
   ASN116BITCHAR* data;
 
} Asn116BitCharString;
 

The ASN116BITCHAR type used in this definition is defined to be an "unsigned short".

See the rtBMPToCString, rtBMPToNewCString, and the rtCToBMPString run-time function descriptions for information on utilities that can convert standard C strings to and from BMP string format.

The UniversalString type is a 32-bit character string for which the following structure is used:

typedef struct {
 
   ASN1UINT       nchars;
 
   ASN132BITCHAR* data;
 
} Asn132BitCharString;
 

The ASN132BITCHAR type used in this definition is defined to be an "unsigned int".

See the rtUCSToCString, rtUCSToNewCString, and the rtCToUCSString run-time function descriptions for information on utilities that can convert standard C strings to and from Universal Character Set (UCS-4) string format. See also the rtUCSToWCSString and rtWCSToUCSString for information on utilities that can convert standard wide character string to and from UniversalString type.

Utilities are also provided for working with UTF-8 string dataThe contents for this string type are assumed to contain the UTF-8 encoding of a character string. The UTF-8 encoding for a standard ASCII string is simply the string itself. For Unicode strings represented in C/C++ using the wide character type (wchar_t), the run-time functions rtUTF8ToWCS and rtWCSToUTF8 can be used for converting to and from Unicode. The function rtValidateUTF8 can be used to ensure that a given UTF-8 encoding is valid. See the Run-Time Common Library section for a complete description of these functions.



Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX