
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 (const 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.
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 GraphicStringOf these, all are represented by const 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 { OSUINT32 nchars; OSUNICHAR* data; } Asn116BitCharString;The OSUNICHAR type used in this definition represents a Unicode character (UTF-16) and is defined to be a C unsigned short type.
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.
typedef struct { OSUINT32 nchars; OS32BITCHAR* data; } Asn132BitCharString;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 data. The contents of 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 UTF-8 format. The function rtValidateUTF8 can be used to ensure that a given UTF-8 encoding is valid. See the C/C++ Run-Time Library Reference Manual for a complete description of these functions.
Objective Systems, Inc.102 Pickering Way, Suite #506Exton, 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 |