By default in the OSS encoders (both space-optimized and time-optimized encoders), the Basic Encoding Rules (BER) are used. You can switch to other encoding rules by following the instructions here.
To switch to the Distinguished Encoding Rules (DER), you can call the ossSetEncodingRules() function at run time before you call the ossEncode() as follows:
When using the time-optimized runtime, you need to make sure that you specified both the -ber and -der ASN.1 compiler command line options in order to be able to switch between BER and DER.
The above function call will instruct the encoder to use DER on the next and subsequent calls. To make the encoder switch back to BER, you can issue the following function call:
When using the space-optimized runtime, to switch to PER (ALIGNED variant), you have to ASN.1-compile (or re-ASN.1-compile) your ASN.1 specification with the -per or -uper command-line option specified. Then, you should issue the following function call before calling the encoder with the data you wish to encode with PER:
Similarly to switch to UPER (UNALIGNED variant) you have to ASN.1- compile (or re-ASN.1-compile) your ASN.1 specification with the -per or -uper command-line option specified. Then, you should issue the following function call before calling the encoder with the data you wish to encode with UPER:
When using the time-optimized runtime, you need to explicitly specify -per and -uper in order to be able to switch between PER ALIGNED and PER UNALIGNED at run time.
The second parameter, rules, can be one of the following: OSS_BER, OSS_CER, OSS_DER, OSS_PER_ALIGNED, OSS_PER_UNALIGNED, OSS_XER, OSS_CXER or OSS_EXER, OSS_OER, OSS_COER, or OSS_JSON. Keep in mind that when compiling you will get BER by default but will need to include one of the following compiler options to use any of the other encoding rules at runtime: -cer, -der, -per, -uper, -xer, -cxer, or -exer.
The samples included with some of the Knowledge Center answers are meant for your general understanding of the OSS products. Different versions of the products might produce slightly different outputs. Consult the products documentation and samples for the most up-to-date products information and code examples.
Test drive the OSS Nokalva ASN.1, LTE, and XML Tools now! Your trial includes complete software, documentation, sample programs, free 24x7 technical support and more.
Our expert personnel can help you learn ASN.1!
We offer 4-day ASN.1 courses at our headquarters or your premises.