The CCSIDCVT keyword allows you to control how the compiler handles
conversions between data with different CCSIDs.
When two CCSIDs support different character sets, it is possible for a character
in one CCSID not to have a matching character in the other CCSID.
For example, the Japanese and Thai character sets each contain many characters
that are not part of the other character set.
If a UCS-2 variable contains both Japanese and Thai characters, and the UCS-2 variable
is converted to a Japanese Graphic variable, the Thai characters will not have matching
characters in the DBCS variable.
When the conversion cannot find a matching character in the target character set,
the conversion will place a substitution character in the
target variable.
The substitution character for alphanumeric data is x'3F'.
The substitution character for Graphic data is x'FEFE'.
One or both parameters may be specified for the CCSIDCVT keyword.
If both parameters are specified, they are separated by a colon.
They may be specified in any order.
- CCSIDCVT(*EXCP : *LIST)
- CCSIDCVT(*LIST : *EXCP)
- CCSIDCVT(*LIST)
- CCSIDCVT(*EXCP)
- *EXCP
- *EXCP indicates that when a conversion results in a substitution
character at run time, that it will cause an RPG exception with
status code 452.
- *LIST
- *LIST indicates that the compiler should add a section to the listing
indicating all the implicit and explicit CCSID conversions,
with an indication of which conversions could result in loss of data
due to substitution
characters being placed in the result because of the lack of matching characters
in the target character set.
Note: The CCSID Conversion Summary section of the listing is only available
when the program or module is created.
It will not be created if there are compile-time errors or if OPTION(*NOGEN)
is specified for the compile.
You can use this information for two purposes:
- You can improve performance by reducing the number of conversions by changing the
data types of some of your variables.
- You can improve the reliability of your program by eliminating some
of the conversions that have the potential to result in substitution characters.
For example, if you have a conversion from UCS-2 to a alphanumeric variable, and that
alphanumeric data is later converted back to UCS-2, you may be able to change the
type of the alphanumeric variable to UCS-2, to avoid the potential data loss.
The following types of conversions can result in substitution characters:
- Conversion from UCS-2 to alphanumeric or DBCS
- Conversion between two different DBCS CCSIDs
- Conversion from alphanumeric to DBCS
- Conversion from DBCS to alphanumeric
For each CCSID conversion used in the module, there is a list of the
statement numbers with that conversion.
See Conversions for more information.
If the conversion could result in substitution characters, a message number
will be shown to the left of the conversion entry.
That message will appear in the Message Summary at the end of the compile.
The following special values are used for some CCSIDs whose value is not known until runtime:
- *JOBRUN
- The job CCSID, or the default job CCSID if the job CCSID is 65535.
This is default the CCSID for alphanumeric data in the RPG module
if CCSID(*CHAR : *JOBRUN) is specified in the Control specification.
- *JOBRUN_MIXED
- The mixed-byte CCSID related to the job CCSID, or related to the
default job CCSID if the job CCSID is 65535.
This CCSID may be the same as the actual job CCSID, if the job CCSID
is a mixed-byte CCSID.
This is the default CCSID for alphanumeric data in the RPG module
if neither CCSID(*CHAR : *JOBRUN)
nor CCSID(*EXACT) is
specified in the Control specification.
See CCSID control keyword for more information.
- *JOBRUN_DBCS
- The double-byte CCSID related to the job CCSID, or related to the default job CCSID if the job CCSID is 65535. This CCSID may be used as the CCSID of the non-shift alphanumeric data for conversions between alphanumeric data and graphic data.
- *JOBRUN_JAVA
- The CCSID used for parameters and return values of Java™ methods when the RPG parameter or return value is defined as alphanumeric. The RPG compiler assumes that this CCSID is related to the job CCSID, so the RPG compiler assumes that there will be no possibility of the conversion resulting in substitution characters.
The following example shows a CCSID Conversion Summary.
The first entry shows that six statements have conversions
from alphanumeric data in the job CCSID to UCS-2 data with CCSID 1200.
The second entry shows that three statements have conversions from
UCS-2 data with CCSID 1200 to alphanumeric data in the job CCSID.
The message
RNF7357 preceding the second entry indicates that these conversions
could result in substitution characters being placed in the alphanumeric data.
Figure 1. Sample CCSID Conversion Summary C C S I D C o n v e r s i o n s
From CCSID To CCSID References
*JOBRUN 1200 27 12 321 426
552 631
RNF7357 1200 *JOBRUN 28 921 1073
* * * * * E N D O F C C S I D C O N V E R S I O N S * * * * *