Skip to content
systemcoding.dev
Mainframe

Convert EBCDIC to ASCII with iconv -f IBM-1047

Convert an EBCDIC file to ASCII on z/OS UNIX with iconv -f IBM-1047 -t ISO8859-1, and why code page 1047 matters for brackets.

1 min read
Summarize in AI

On z/OS UNIX System Services in z/OS 3.1, iconv converts a file between code pages, and the codeset names are the z/OS ones: IBM-1047 for the EBCDIC side and ISO8859-1 for Latin-1 ASCII. Suppose hello.ebc holds the five bytes C8 C5 D3 D3 D6.

Shell
iconv -f IBM-1047 -t ISO8859-1 hello.ebc > hello.txt
cat hello.txt
Text
HELLO

Choose the code page deliberately. IBM-1047 is the default for z/OS UNIX and the C compilers, while most COBOL and CICS data uses IBM-037, and the two differ on a handful of characters. The square brackets are X'AD' and X'BD' in 1047 but X'BA' and X'BB' in 037, and the caret is X'5F' in 1047 against X'B0' in 037. Convert 037 data with 1047 and your JSON arrays or array subscripts come out as the wrong symbols.

The z/OS documentation lists the supported codesets. Binary and packed fields inside the record must never go through iconv, because it would translate their bytes as if they were text.

Taggedussz os 3
Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.