String descriptors

In a string descriptor, the first 2 bytes specify the maximum length for the string. This maximum length is always held in native format.

The third byte contains various flags (to indicate, for example, if the string length in a VARYING string is held in littleendian or bigendian format or if the data in a WIDECHAR string is held in littleendian or bigendian format).

In a string descriptor for a nonvarying bit string, the fourth byte gives the bit offset.

In a string descriptor for a CHARACTER string, the fourth byte encodes the compiler CODEPAGE option.

The declare for a string descriptor under CMPAT(V1) and CMPAT(V2) is as follows:

declare
  1 dso_string based,
    2 dso_string_length          fixed bin(15),
    2 dso_string_flags,
      3 dso_string_is_varying           bit(1),
      3 dso_string_is_varyingz          bit(1),
      3 dso_string_has_nonnative_len    bit(1), /* for varying     */
      3 dso_string_is_ascii             bit(1), /* for char        */
      3 dso_string_has_nonnative_data   bit(1), /* for wchar       */
      3 *                               bit(1), /* reserved, '0'b  */
      3 *                               bit(1), /* reserved, '0'b  */
      3 *                               bit(1), /* reserved, '0'b  */
    2 * union,
      3 dso_String_Codepage      ordinal ccs_Codepage_Enum,
      3 dso_string_bitofs        fixed bin(8) unsigned,
    2 dso_string_end     char(0);

The declare for a string descriptor under CMPAT(V3) is as follows:

declare
  1 dso_longstr based,
    2 dso_longstr_info,
      3 *                   fixed bin(8) unsigned,
      3 dso_datatype        fixed bin(8) unsigned,
      3 * union,
        4 dso_longstr_bitofs    fixed bin(8) unsigned,
        4 dso_longstr_codepage  type ccs_Codepage_Enum,
      3 dso_longstr_info2,
        4 dso_longstr_has_nonnative_len   bit(1), /* for varying    */
        4 dso_longstr_is_ebcdic           bit(1), /* for char       */
        4 dso_longstr_has_nonnative_data  bit(1), /* for wchar      */
        4 *                               bit(1),
        4 dso_longstr_is_varying          bit(1),
        4 dso_longstr_is_varyingz         bit(1),
        4 dso_longstr_is_varying4         bit(1),
        4 *                               bit(1),
    2 dso_longstr_length          fixed bin(31),
    2 dso_longstr_end     char(0);              

The possible values for the codepage encoding are defined as follows:

define ordinal
  ccs_Codepage_Enum
    ( ccs_Codepage_01047  value(1)
     ,ccs_Codepage_01140
     ,ccs_Codepage_01141
     ,ccs_Codepage_01142
     ,ccs_Codepage_01143
     ,ccs_Codepage_01144
     ,ccs_Codepage_01145
     ,ccs_Codepage_01146
     ,ccs_Codepage_01147
     ,ccs_Codepage_01148
     ,ccs_Codepage_01149
     ,ccs_Codepage_00819
     ,ccs_Codepage_00813
     ,ccs_Codepage_00920
     ,ccs_Codepage_00037
     ,ccs_Codepage_00273
     ,ccs_Codepage_00277
     ,ccs_Codepage_00278
     ,ccs_Codepage_00280
     ,ccs_Codepage_00284
     ,ccs_Codepage_00285
     ,ccs_Codepage_00297
     ,ccs_Codepage_00500
     ,ccs_Codepage_00871
     ,ccs_Codepage_01026
     ,ccs_Codepage_01155
    ) unsigned prec(8);