f_control_cvt
Function
f_control_cvt controls automatic file conversion and specifies the program and file CCSIDs (character code set identifiers) for an opened I/O stream.
Parameters
- fd
- The file descriptor (a number) for the file. It must be a regular file, FIFO, or character special file.
- command
- The command can
be one of these variables:
- CVT_SETCVTOFF
- Turns off any conversion that might be in effect. A hexadecimal value of 0 for both program-ccsid and file-ccsid is recommended. If automatic conversion is set to ALL and I/O has already started for the file, this command is ignored.
- CVT_SETCVTON
- Turns automatic conversion on for the stream and, optionally,
sets the program CCSID or file CCSID, or both. A hexadecimal value
of 0 for program-ccsid indicates using ThliCcsid
(the current program CCSID) at the time of each read or write. ThliCcsid
is initially 1047, but can be reset directly by the program, or indirectly
by setting the appropriate runtime option or environment variable.
A hex value of 0 for file-ccsid indicates
not changing ThliCcsid.
Setting or referencing ThliCcsid is still valid but not recommended.
- CVT_SETAUTOCVTON
- Conditionally turns automatic conversion on for the stream and, optionally, sets the program CCSID or file CCSID, or both. Conversion will be in effect for this stream only if the system or the local runtime environment has been enabled for conversion. A hex value of 0 for program-ccsid indicates using ThliCcsid at the time of each read or write. ThliCcsid is initially 1047, but can be changed by this variable, or by setting the appropriate runtime option or environment variable. A hex value of 0 for file-ccsid indicates not changing ThliCcsid.
- CVT_QUERYCVT
- Returns an indicator that lets you know whether automatic conversion is in effect or not, and also returns the program and file CCSIDs that are being used (if conversion is in effect). The variables command, program-ccsid, and file-ccsid are set when you have a successful return. command is set to either CVT_SETCVTOFF or CVT_SETCVTON or CVT_SETCVTALL. program-ccsid and file-ccsid are set to the CCSID values that would be in use if conversion were to occur.
- CVT_SETCVTALL
- Behaves the same as SetCvtOn, except automatic conversion is set to ALL, which enables UNICODE conversion. ThliCcsid is not used. CVT_SETCVTALL is ignored if I/O for the file has already started. A thread can set different program CCSIDs for each open file. However, an I/O error will result if any two threads have different program CCSIDs for the same open file that is shared by those two threads.
- CVT_SETAUTOCVTALL
- If conversion is enabled for the environment (by BPXPRMxx parmlib statement AUTOCVT setting of ALL or with the appropriate environment variable), this subcommand behaves identically to CVT_SETCVTALL. Otherwise, it has no effect.
- program-ccsid
- The name of a 2-byte hex variable that describes the CCSID for
the running program. Note: For EBCDIC (1047) the CCSID is '0417'X; for ASCII (819) it is '0333'X.
- file-ccsid
- The name of a 2-byte hex variable that describes the CCSID for the file opened with the file descriptor fd.
Usage notes
- When the file is /dev/null, /dev/zero, /dev/random, or /dev/urandom, the file tag is not hardened to disk.
Example
This example turns automatic file
conversion on for a stream opened with fd as
the file descriptor:
pccsid = '0000'x
fccsid = '0000'x
cmd = cvt_setautocvton
"f_control_cvt (fd) cmd pccsid fccsid"
This example queries
the current conversion state: pccsid = '0000'x
fccsid = '0000'x
cmd = cvt_querycvt
"f_control_cvt (fd) cmd pccsid fccsid"