Understanding Character Set Conversion

The COBOL Unicode conversion utility for z/OS updates COBOL programs to use Unicode for all character data for internal processing, including numbers and date. However, there maybe cases where the Unicode data must be converted to non-Unicode character set, typically when communicating with external systems that do not fully support Unicode.

The following table lists IBM Enterprise COBOL statements and functions that convert between Unicode and non-Unicode character sets.

Statement/Function Description

MOVE

This statement converts data in system EBCDIC character set to Unicode in the following syntax:

move PIC X field or alphanumeric string literal ⇒
to PIC N field

Note: Using the statement move PIC N field or national literal to PIC X causes a compiler error. When converting from Unicode data item to non-Unicode, you must insert the DISPLAY-OF() function to convert the Unicode data to non-Unicode first.

DISPLAY-OF()

This function converts data from Unicode to a non-Unicode character. The DISPLAY-OF() function has two forms:

  • The following converts from Unicode to system EBCDIC character set.

    FUNCTION DISPLAY-OF(PIC N field or national⇒
     literal)
  • The following converts from Unicode to a character set specified in the CCSID parameter.

    FUNCTION DISPLAY-OF(PIC N field or national⇒
     literal, CCSID)

NATIONAL-OF()

This function converts data from a non-Unicode character set to Unicode. NATIONAL-OF() function has two forms:

  • The following converts from the system EBCDIC character set to Unicode.

    FUNCTION NATIONAL-OF(PIC X field or alphanumeric⇒
     literal)
  • The following converts from a character set specified in the CCSID parameter to Unicode.

    FUNCTION NATIONAL-OF(PIC X field or alphanumeric⇒
     literal, CCSID)

Note:

To change the newline characters, use one of transformations - NewLine LF, NewLine CR, or NewLine CRLF at the end of the command. This utility is available to use in the bin directory.