How EBCDIC to ASCII conversion works in TextPipe
Mainframe systems from IBM, Unisys and others store text in EBCDIC, a character encoding that does not match the ASCII or ANSI encodings used by Windows, Linux and most databases. A byte that represents the letter A in EBCDIC (hex C1) is a completely different character if you open the file in an ordinary editor. Copying such a file to a PC and loading it into Excel or SQL Server produces unreadable output. Conversion must happen before the data can be used.
A plain character-by-character translation is only half of the job. Real mainframe files are usually a mix of text fields, packed decimal numbers, zoned numbers and binary integers, all laid out in fixed-width records that are described by a COBOL copybook. If you run a packed field through a character translation, the numeric value is destroyed. TextPipe reads the copybook, works out the offset, length and type of every field, and converts each field with the correct method. Text fields go through the EBCDIC code page you select, and numeric fields are decoded into readable digits with the sign and decimal point restored.
Sample input and output
A customer record is defined in the copybook as follows:
01 CUST-REC.
05 CUST-ID PIC 9(6).
05 CUST-NAME PIC X(20).
05 BALANCE PIC S9(7)V99 COMP-3.
05 STATUS-CODE PIC X(1).
The raw EBCDIC record is shown here as hex, because the packed balance contains bytes that have no printable form:
F0F0F1F2F3F4 C1C4C1D440D1D6D5C5E2(+10 x 40) 001234567C D9
After conversion to pipe-delimited ASCII, the same record reads:
001234|ADAM JONES|12345.67|R
The packed balance 001234567C (five bytes) decodes to 1234567 if the V99 scale is ignored, which is a common mistake in hand-written conversion scripts. TextPipe applies the implied decimal from the PICTURE clause, so the value arrives as 12345.67, and the trailing sign nibble C is interpreted as positive.
Typical settings
- Copybook: load the COBOL copybook so that field boundaries, COMP-3 and COMP fields, REDEFINES and OCCURS DEPENDING ON groups are known.
- Code page: choose the EBCDIC code page used by the source system, for example IBM037 for US data or IBM500 for international data.
- Output layout: write CSV, tab-delimited, pipe-delimited or fixed width text, depending on what the target database or spreadsheet expects.
- Record length: specify the fixed record length when the file has no record delimiters, which is the usual case for files transferred in binary mode.
Practical applications
Banks use this approach to move nightly transaction extracts from a mainframe into reporting databases. Utilities and government agencies use it to rescue archived data from tape dumps when the original program no longer exists. Systems integrators use it to load legacy customer data into modern platforms during migrations. In each of these cases the files are often several gigabytes in size, and TextPipe processes them as a stream, so memory use stays flat regardless of file size.
Common pitfalls
- Transferring the file from the mainframe with FTP in ASCII mode corrupts packed fields. Always transfer in binary mode and convert on the PC.
- Using the wrong code page converts most letters correctly but mangles characters such as square brackets, the pound sign and the not sign.
- A copybook that omits FILLER or slack bytes will shift every following field. Check that the total of the field lengths matches the record length.
Related pages
See the EBCDIC to ASCII feature guide for filter-level detail, and COMP-3 packed decimal conversion for numeric field handling. The banking and finance case study shows a COBOL conversion project in practice, and the data conversion solutions page covers wider format migration scenarios. If you need to strip or rewrite text inside Word files after conversion, WordPipe performs the same kind of batch replacement on documents.