Specifying the code page for character data
In a source program, you can use the characters that are
represented in a supported code page in COBOL names, literals, and
comments. At run time, you can use the characters
that are represented in a supported code page in data items described
with USAGE DISPLAY, USAGE DISPLAY-1,
or USAGE NATIONAL.
About this task
The code page that is in effect for a particular data item depends on the following aspects:
- Which
USAGEclause you used - Whether you used the
NATIVEphrase with theUSAGEclause - Whether you used the
CHAR(NATIVE)orCHAR(EBCDIC)compiler option - The value of the EBCDIC_CODEPAGE environment variable
- Which locale is active
For USAGE NATIONAL data items, the code page is always
UTF-16 in big-endian format.
For USAGE DISPLAY data items, COBOL for AIX chooses between ASCII, UTF-8, EUC, and EBCDIC code pages as
follows:
- Data items that are described with the
NATIVEphrase in theUSAGEclause or that are compiled with theCHAR(NATIVE)option in effect are encoded in an ASCII, EUC, or UTF-8 code page. - Data items that are described without the
NATIVEphrase in theUSAGEclause and that are compiled with theCHAR(EBCDIC)option in effect are encoded in an EBCDIC code page.
For
USAGE DISPLAY-1 data items, COBOL for AIX chooses between ASCII and
EBCDIC code pages as follows: - Data items that are described with the
NATIVEphrase in theUSAGEclause or that are compiled with theCHAR(NATIVE)option in effect are encoded in an ASCII DBCS code page. - Data items that are described without the
NATIVEphrase in theUSAGEclause and that are compiled with theCHAR(EBCDIC)option in effect are encoded in an EBCDIC DBCS code page.
COBOL determines the appropriate code page as follows:
- ASCII, UTF-8, EUC
- From the active locale at run time
- EBCDIC
- From the EBCDIC_CODEPAGE environment variable, if set, otherwise the default EBCDIC code page from the current locale setting
related references
Locales and code pages that are supported
Runtime environment variables
CHAR
COBOL words with single-byte characters
(COBOL for AIX Language Reference)
User-defined words with multibyte characters
(COBOL for AIX Language Reference)
Locales and code pages that are supported
Runtime environment variables
CHAR
COBOL words with single-byte characters
(COBOL for AIX Language Reference)
User-defined words with multibyte characters
(COBOL for AIX Language Reference)