When a file is opened, a CCSID is associated with
it. Read operations of character and string values return data in
the CCSID of the file. Write operations to the file expect the data
in the CCSID of the file. The CCSID associated with a file when it
is opened is dependent on the function that is used to open the file:
catopen function
The CCSID associated with a catalog
file that is opened using catopen depends on the content
of the oflag parameter. Two of the flags that can be specified for
the oflag parameter are NL_CAT_JOB_MODE and NL_CAT_CTYPE_MODE. These
flags are mutually exclusive.
If NL_CAT_JOB_MODE is specified, the job CCSID is associated with
the file.
If NL_CAT_CTYPE_MODE is specified, the CCSID of the LC_CTYPE category
of the current locale is associated with the file.
If neither flag is specified, no conversion takes place and the
CCSID of the returned messages is the same CCSID as that of the message
file.
fdopen() function
If LOCALETYPE(*LOCALEUTF) is not specified, then the default CCSID
for a file is the job CCSID. The keyword ccsid=value, o_ccsid=value,
or codepage=value can be used in the mode string on the file open
command to change the CCSID associated with the file. o_ccsid=value
is the recommended keyword. The standard files are always associated
with the default file CCSID, so they are associated with the job CCSID.
If LOCALETYPE(*LOCALEUTF) is specified, then the default CCSID
for a file is the CCSID of the LC_CTYPE category of the current locale
when the fopen() function is called. The keywords described
in the previous paragraph can still be used to override the CCSID
associated with the file. The standard files are always associated
with the default file CCSID, so they are associated with the CCSID
of the LC_CTYPE category of the current locale when they are opened.
fopen() and freopen() functions
If LOCALETYPE(*LOCALEUTF) is not specified, the default CCSID
for a file is the job CCSID.
If SYSIFCOPT(*NOIFSIO) is specified on the compilation command,
the keyword ccsid=value can be used in the mode string on the file
open command to change the CCSID of data read from or written to the
file.
If SYSIFCOPT(*NOIFSIO) is not specified on the compilation command,
the keyword ccsid=value, o_ccsid=value, or codepage=value can be used
in the mode string on the file open command to change the CCSID associated
with the file. o_ccsid=value is the recommended keyword.
The standard files are always associated with the default file
CCSID, so they are associated with the job CCSID.
If LOCALETYPE(*LOCALEUTF) is specified, then the default CCSID
for a file is the CCSID of the LC_CTYPE category of the current locale
when the fopen() or freopen() function is called.
The keyword ccsid=value, o_ccsid=value, or codepage=value can still
be used to override the CCSID associated with the file. The standard
files are always associated with the default file CCSID, so they are
associated with the CCSID of the LC_CTYPE category of the current
locale when they are opened.
_Ropen() function
The default CCSID associated with
a file opened with the _Ropen() function is the job CCSID.
The ccsid=value keyword can be used in the mode parameter on the _Ropen() function
to change the CCSID associated with the file.
wfopen() function
If LOCALETYPE(*LOCALEUCS2) is specified, the default CCSID for
a file is UCS-2. The keyword ccsid=value, o_ccsid=value, or
codepage=value can be used in the mode string on the file open command
to change the CCSID associated with the file. o_ccsid=value is the
recommended keyword.
If LOCALETYPE(*LOCALEUTF) is specified, then the default CCSID
for a file is UTF-32. The keywords described in the previous paragraph
can still be used to override the CCSID associated with the file.