Processing UTF-8 data
To process UTF-8 data, first convert the UTF-8 data to
UTF-16 in a national data item. After processing the national data,
convert it back to UTF-8 for output. For the conversions, use the
intrinsic functions NATIONAL-OF and DISPLAY-OF,
respectively. Use code page 1208 for UTF-8 data.
About this task
Take the following steps to convert ASCII or EBCDIC data to UTF-8 (unless the code page of the locale in effect is UTF-8, in which case the native alphanumeric data is already encoded in UTF-8):
Procedure
- Use the function
NATIONAL-OFto convert the ASCII or EBCDIC string to a national (UTF-16) string. - Use the function
DISPLAY-OFto convert the national string to UTF-8.
Results
The following example converts Greek EBCDIC data to UTF-8:
Usage note: Use care if you use reference modification to refer to data encoded in UTF-8. UTF-8 characters are encoded with a varying number of bytes per character. Avoid operations that might split a multibyte character.

