Using FMTOPT(*MAP) to copy to a UTF-8 character or UTF-16 graphic field converts the data in the from-field CCSID to the CCSID of the UTF-8 character or UTF-16 graphic to-field. If the length after conversion is less than the length of the UTF-8 or UTF-16 graphic to-field, the field is padded. If the length after conversion is greater than the length of the UTF-8 character or UTF-16 graphic to-field, the field is truncated.
Using FMTOPT(*MAP) to copy from a UTF-8 character or UTF-16 graphic field converts the data from the CCSID of the UTF-8 character or UTF-16 graphic field to the CCSID of the to-field. If the length after conversion is less than the length of the to-field, the field is padded. If the length after conversion is greater than the length of the to-field, the field is truncated.
UTF-8 or UTF-16 conversion possibilities also include variable length fields. Generally, the result length of a variable length to-field will be the minimum of the from-field converted length and the maximum length of the to-field.
The CCSID conversions created when copying from or to a UTF-8 or UTF-16 field might cause the byte length of the data to be different after the conversion. The maximum length of the to-field is used to determine if all of the converted data will fit in the to-field.
When copying from a UTF-8 or UTF-16 field to a character field, or to a DBCS-either field where the first byte is already converted to a valid SBCS character (not a shift-out X'0E'), any remaining characters that cannot be converted to SBCS (actual double-byte data in the UTF-8 or UTF-16 field) will have a single-byte substitution character set in its place.
When copying from a UTF-8 or UTF-16 field to a DBCS-only, DBCS-graphic field, or to a DBCS-either field where the first byte is already converted to a DBCS shift-out (X'0E'), any remaining characters that cannot be converted to DBCS will have a double-byte substitution character set in its place.
To be successful when using FMTOPT (*MAP) to convert from or to a UTF-8 or UTF-16 data, the resulting converted data for the to-field must conform to the to-field type. Otherwise, conversion errors will occur and the to-field will be set to its default value.
FMTOPT (*MAP) has to be specified when you copy from a non-normalize file to a normalize file. The to file will be a normalize file in any cases described in the following table:
FromFile (non-normalize) | ToFile (normalize) |
---|---|
UTF-8 | UTF-8 |
UTF-8 | UTF-16 |
UTF-16 | UTF-16 |
UTF-16 | UTF-8 |
UCS2 | UTF-8 |
UCS2 | UTF-16 |