Problem
Is it possible to print a Unicode file for a COBOL program when the local language is different to Unicode?
Resolution
Before the file can be printed, it needs to be converted from Unicode (ie UTF-8) to the local code page (in this case CP-864). This conversion is done using the standard Linux/Unix command iconv.
The attached COBOL program performs the following tasks:
- Call iconv in open to prepare to convert the file
- Calls iconv to perform the conversion from UTF-8 (Unicode) to CP-864 (Arabic)
- Call iconv to close and release its resources.
The program has been written as a subprogram so that it can be called prior to the output being sent to the printer. The program uses the following parameters when making the call to iconv:
- The UTF8 buffer (input buffer)
- The CP864 buffer (output buffer)
- The size of the UTF8 buffer
- The size of the CP864 buffer
More information about iconv can be found in the standard Linux on-line manual (if it is installed), by using the command:
man iconv
Incident: <?>
#iconv
#unicode
#utf-8