IBM Support

How to Add Byte-Order-Mark BOM Codes to a STMF Created by CPYTOIMPF in UTF-8

Troubleshooting


Problem

CPYTOIMPF does not add BOM codes to a UTF-8 streamfile to clearly identify it as a UTF-8 file on other platforms. This document includes information on how to add them.

Resolving The Problem

CPYTOIMPF does not add BOM codes to a UTF-8 streamfile to clearly identify it as a UTF-8 file on other platforms. This document includes information on how to add them.

CPYTOIMPF was used to create an export streamfile in UTF-8 (CCSID 1208) format. When the file contained special characters such as umlauts, the receiving application correctly identified the UTF-8 encoding. However, with only plain Latin characters, the target application assumed ANSI encoding and refused the import. BOM characters (see Unicode Transformation Formats) were missing to uniquely identify the field contents.

The following are valid BOM characters:

BOMSHex values
UTF-32 BE (020)00 00 FE FF
UTF-32 LE (030)FF FE 00 00
UTF-16 BE (040)FE FF
UTF-16 LE (050)FF FE
UTF-8 (060)EF BB BF

You should do the following to correct this issue:
1.Create a UTF-8 streamfile with the correct UTF-8 BOM characters X'EFBBBF'. (make sure the STMF is CCSID 1208 and the contents is unchanged):

Windows Notepad can be used to generate that file. You should open a new, empty file and use Save As to specify UTF-8 format:

Creating an UTF-8 text file in Windows Notepad



utf8bom.zip
2.Type the following ahead of the export file:

CPY OBJ('utf8bom.txt')
TOOBJ('newfile.txt')
FROMCCSID(1208)
TOCCSID(1208)
REPLACE(*YES)

CPYTOIMPF FROMFILE(<Table>)
TOSTMF('newfile.txt')
STMFCCSID(1208) (or for V5R4: STMFCODPAG(1208))
MBROPT(*ADD)

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Historical Number

629017082

Document Information

Modified date:
18 December 2019

UID

nas8N1011066