The CODE-SET clause specifies the character code set used to represent
data on the external media.
It can be specified only for files with record sequential
and line sequential
organization.
Although it is a part of the standard
COBOL definition, this feature is explicitly excluded from the X/Open COBOL
language definitions and should not be used in a conforming X/Open COBOL source
program.
General
Format

Directives
- In addition to Compiler directives which provide flagging and modify
the reserved word list, the following directive may impact either the syntax or
the semantics described in this section.
- CHARSET – determines what is considered the native code set.
Syntax Rules
- When the CODE-SET clause is specified for a file, all data in that file
must be described as USAGE IS DISPLAY and any signed numeric data must be
described with the SIGN IS SEPARATE clause.
These restrictions do not apply.
- The alphabet-name clause referenced by the CODE-SET clause must not
specify the literal phrase.
These restrictions do not apply.
Identifier-1 can be qualified, but must
not be subscripted.
Each identifier-1 must be a data item
described in the same record description for the file, and must not itself be a
record description.
If the optional FOR phrase is specified,
the CODE-SET clause specifies the character code to be used for the data items
named. If the FOR phrase is not specified, the CODE-SET clause specifies the
character code to be used for the whole file.
- The native character set is used for any file, or data item in a file,
to which no CODE-SET clause applies.
General Rules
The data in the record area is always in
ASCII. If alphabet-name has been equated in the Special-Names paragraph to
EBCDIC, then data affected by the CODE-SET clause is translated from ASCII to
EDCDIC as it is written to the file; or from EBCDIC to ASCII as it is read from
the file. If alphabet-name has been equated in the Special-Names paragraph to
STANDARD-1, STANDARD-2, NATIVE, or ASCII, no translation is necessary.
For the purposes of this translation, any
data item to which a CODE-SET clause applies is treated as alphanumeric. No
account is taken of the class and category of the item as described in its data
description.
If identifier-1 has an OCCURS clause, the
CODE-SET clause applies to only the first occurrence of it. If identifier-1 has
a subordinate item with an OCCURS clause, the CODE-SET clause applies to the
whole of identifier-1.