Previous Topic Next topic Print topic


Appendix C - Elementary Data Format Conversions

Elementary data items within identifier-2 are converted in the sequence of the following steps. Some of these steps are optional.

Conversion to character format:

Elementary data items are converted to character format depending on the type of the data item:

  • The following data items are not converted to character format, except when Unicode encoding is required:
    • alphabetic
    • alphanumeric
    • alphanumeric-edited
    • DBCS
    • external floating-point
    • national
    • national-edit
    • numeric-edited
  • The following data items are converted to character format:
    • fixed-point numeric
      • Fixed-point numerics other than COMPUTATIONAL-5 (COMP-5) binary data items or binary data items compiled with the TRUNC(BIN) Compiler directive are converted as if they were moved to a numeric-edited item that has:
        • As many integer positions as the numeric item has, but with at least one integer position (possibly zero), and the same number of decimal positions as the numeric item
        • An explicit decimal point, if the numeric item has at least one decimal position; the DECIMAL-POINT IS COMMA clause in the SPECIAL-NAMES paragraph, if specified, is ignored.
        • A leading '-' picture symbol if the data item is signed (that is, has an S in its PICTURE clause)
      • Fixed-point numerics that are COMPUTATIONAL-5 (COMP-5) binary data items or binary data items compiled with the TRUNC(BIN) compiler option are converted as those above except that the number of decimal positions is dependent on the number of '9' symbols in the picture character string:
        • 5 minus the number of decimal places, if the data item has 1 to 4 '9' picture symbols
        • 10 minus the number of decimal places, if the data item has 5 to 9 '9' picture symbols
        • 20 minus the number of decimal places, if the data item has 10 to 18 '9' picture symbols
    • internal floating-point
      • Internal floating-point data items are converted as if they were moved to a data item as follows:
        • For COMP-1: an external floating-point data item with PICTURE -9.9(8)E+99
        • For COMP-2: an external floating-point data item with PICTURE -9.9(17)E+99 (illegal because of the number of digit positions)
    • external floating-point
      • External floating-point data items are converted as if they were moved to another external floating-point data item with the same precision and scale, and with:
        • A - sign for the mantissa.
        • An actual decimal point, indicated by a . PICTURE symbol.
        • A + sign for the exponent.

        For example, an external floating-point item defined with PICTURE -9(4)V9(2)E-99 would be converted as if it were moved to an external floating-point item defined with PICTURE -9(4).9(2)E+99.

    • index data items
      • Index data items are converted as if they were declared USAGE COMP-5 PICTURE S9(9).

Trimming

Trimming occurs after any conversion to character format; see Appendix E - Trimming of Generated JSON Data for more information.

Conversion to the target encoding

All values are represented in UTF-8 format unless identifier-1 is a national data item; in which case, any non-national values are converted to national format.

Escaping characters

The following table shows the conversion of common characters to their two-character escape sequences:

Note: The characters NX'0022' (") and NX'005C' (\) are escaped as \" and \\, respectively.
Coded value Escape sequence Description
NX'0008' \b backspace
NX'0009' \t tab
NX'000A' \n line feed
NX'000C' \f form feed
NX'000D' \r carriage return
NX'0085' \x next line

The remaining characters in the range NX'0000' through NX'001F' are escaped as \uhhhh, where h represents a hexadecimal digit 0 through F.

Previous Topic Next topic Print topic