How To
Summary
This document explains how to add a BOM (Byte Order Marker) to a new IBM i OS IFS text file. There are still some third-party (non IBM i OS) applications that require a BOM to understand the file encoding is UTF-8 or UTF-16.
Objective
Unicode text files may be encoded in several formats, including UTF-8, UTF-16, and UTF-32. Each of these formats can be prefixed with a byte order mark (BOM) that indicates the byte ordering used when the text was written.
IBM i does not need this as files are tagged with a CCSID. Non IBM i OS platforms may still require this indicator on the first positions of the file.
In the steps below we will show what can be done to create a new IFS file that contains a BOM for UTF-16.
IBM i does not need this as files are tagged with a CCSID. Non IBM i OS platforms may still require this indicator on the first positions of the file.
In the steps below we will show what can be done to create a new IFS file that contains a BOM for UTF-16.
Environment
For our sample we have an IBM i Table that is tagged with CCSID 875 (Greece) and has only one record.
The content of that record in hex is x/41 till x/FF.
All characters available in Greece codepage 875 are represented.
Below is an overview of Codepage 875

For Euro sign usage, use CCSID 4971 instead of CCSID 875.
Steps
Step A. Create an IBM i Table tagged with CCSID(875) and insert hex data x/41-x/FF
1. Start IBM ACS RunSQLScript and connect to your system.
2. To avoid any false conversion, make sure the job CCSID is set to 875.
CL:CHGJOB CCSID(875);
3. Create an empty IBM i OS Table
CREATE TABLE Your_Schema.HEXDAT0875 ("DATA" CHAR(192) CCSID 875 NOT NULL DEFAULT '')
RCDFMT RECORD;
RCDFMT RECORD;
4. Insert a record with x/41 till x/FF into Your_Schema.HEXDATA0875 table
INSERT INTO Your_Schema.HEXDAT0875
VALUES(X'4142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF');
Step B. Create a IBM i IFS template file that contains the Byte Order Marker (BOM).
1. Create an ACS 5250 session with Host Codepage 875
Click ACS 5250 Tab Communication, Configure, Host Codepage pull down menu and select 875.
Click ACS 5250 Tab Communication, Configure, Host Codepage pull down menu and select 875.
2. When logged in, make sure your job CCSID is set to 875 to avoid any false conversion.
Enter CHGJOB CCSID(875)
3. Make a directory in the IFS /home directory.
Enter MKDIR DIR('\home\Your_Directory')
4. For this session make this the current default directory
Enter CD DIR('\home\Your_Directory')
5. Open a QSHELL terminal.
Enter QSH
6. With QSHELL session opened, create a BOM file
Enter printf '\xff\xfe' > /home/Your_Directory/bom.utf16
When done F3 out of the QSHELL session.
7. Check the content of that IFS file by using the DMP command
Enter DMP OBJ('/home/Your_Directory/bom.utf16')
8. Review the QPSRVDMP spoolfile that was created.
Enter WRKJOB, then option 4 - Work with Spoolfiles.
Put a 5 before the QPSRVDMP file.
Enter SPACE- at the FIND line, and press F16.
The following screen should show up, where you can see the hex values FFFE which is the UTF-16 indicator.

Step C. Combine the IFS UTF-16 BOM file and HEXDAT0875 Db2 Table into one IFS result file.
1. Copy the BOM file to the new final IFS result file.
Use CL command:
CPY OBJ('/home/Your_Directory/bom.utf16') TOOBJ('/home/Your_Directory/ebcdicP875.utf16') TOCCSID(1200)
1. Copy the BOM file to the new final IFS result file.
Use CL command:
CPY OBJ('/home/Your_Directory/bom.utf16') TOOBJ('/home/Your_Directory/ebcdicP875.utf16') TOCCSID(1200)
2. Then enter below command to copy the actual Table (PF) to that new result file.
CPYTOIMPF FROMFILE(Your_Schema/HEXDAT0875) TOSTMF('/home/Your_Directory/ebcdicP875.utf16')
STMFCCSID(1200) RCDDLM(*CRLF) STRDLM(*NONE) FLDDLM(*TAB) MBROPT(*ADD)
STMFCCSID(1200) RCDDLM(*CRLF) STRDLM(*NONE) FLDDLM(*TAB) MBROPT(*ADD)
3. If you want to check the content, you can use the DMP command as in step B7 above.
DMP OBJ('/home/Your_Directory/ebcdicP875.utf16')
4. Review the QPSRVDMP spoolfile that was created:

Enter WRKJOB, then option 4 - Work with Spoolfiles.
Put a 5 before the QPSRVDMP file.
Enter SPACE- at the FIND line, and press F16.

Those UTF-16 Hex Values match with the corresponding 875 x/41-x/FF
Step D. Transfer the final IBM i IFS file /home/Your_Directory/ebcdicP875.utf16 to an external target.
Step D. Transfer the final IBM i IFS file /home/Your_Directory/ebcdicP875.utf16 to an external target.
In our sample we will use IBM i ACS IFS Utility to copy the IFS file to a PC client with MS-Windows using Codepage 1252 (not Greece Codepage 1253).
1. At the ACS Main menu for you system, expand the General tab, and click Integrated File System.
2. Go to your directory - /home/Your_Directory
3. Right click the generated file (per our sample ebcdicP875.utf16) and select one of the Download options you prefer.
Document Location
Worldwide
[{"Type":"MASTER","Line of Business":{"code":"","label":""},"Business Unit":{"code":"","label":""},"Product":{"code":"SSAUTS","label":"Db2 for i5\/OS"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]
Was this topic helpful?
Document Information
Modified date:
02 April 2025
UID
ibm17184952