Introduction
EBCDIC is IBM’s family of 8-bit encodings, from the System/360 (1963 to 1964), and
still the native text of z/OS and IBM i. It is not based on ASCII: the space is
40, the digits are F0 to F9, and the letters
come in three runs. “Hi” is C8 89. There are hundreds of EBCDIC code
pages. No file says which one it uses, so the explorer recognises EBCDIC from its
bytes, guesses a code page, and shows the file in every page it knows.
Files are normally converted to ASCII when they leave the mainframe, so EBCDIC
.txt files are rare on PCs, and no browser decodes EBCDIC. A file dropped
on any page of this site opens in the explorer, which decodes it.
Structure
The file is characters and line endings, with no header. Records of fixed length with no line endings are common on mainframes, and such a file shows as one long line here, because nothing in it marks a record’s length.
0Lines characters of one byte, each line followed by its line endingvaries
Byte order mark
EBCDIC has no byte order mark, and nothing in the file names the code page.
Encoding
Each byte is one character. Letters are in three runs (A–I, J–R, S–Z), with a gap
between each, and lower case at 81 to A9. Code page 037 is
the usual choice for US English; 500 for international; 1047 for z/OS Unix.
Code page 037
Table of every byte. The names are the control codes (ISO 6429), with SP the space, NBSP the no-break space and SHY the soft hyphen.
| _0 | _1 | _2 | _3 | _4 | _5 | _6 | _7 | _8 | _9 | _A | _B | _C | _D | _E | _F | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0_ | NUL | SOH | STX | ETX | ST | HT | SSA | DEL | EPA | RI | SS2 | VT | FF | CR | SO | SI |
| 1_ | DLE | DC1 | DC2 | DC3 | OSC | NEL | BS | ESA | CAN | EM | PU2 | SS3 | FS | GS | RS | US |
| 2_ | PAD | HOP | BPH | NBH | IND | LF | ETB | ESC | HTS | HTJ | VTS | PLD | PLU | ENQ | ACK | BEL |
| 3_ | DCS | PU1 | SYN | STS | CCH | MW | SPA | EOT | SOS | SGCI | SCI | CSI | DC4 | NAK | PM | SUB |
| 4_ | SP | NBSP | â | ä | à | á | ã | å | ç | ñ | ¢ | . | < | ( | + | | |
| 5_ | & | é | ê | ë | è | í | î | ï | ì | ß | ! | $ | * | ) | ; | ¬ |
| 6_ | - | / | Â | Ä | À | Á | Ã | Å | Ç | Ñ | ¦ | , | % | _ | > | ? |
| 7_ | ø | É | Ê | Ë | È | Í | Î | Ï | Ì | ` | : | # | @ | ' | = | " |
| 8_ | Ø | a | b | c | d | e | f | g | h | i | « | » | ð | ý | þ | ± |
| 9_ | ° | j | k | l | m | n | o | p | q | r | ª | º | æ | ¸ | Æ | ¤ |
| A_ | µ | ~ | s | t | u | v | w | x | y | z | ¡ | ¿ | Ð | Ý | Þ | ® |
| B_ | ^ | £ | ¥ | · | © | § | ¶ | ¼ | ½ | ¾ | [ | ] | ¯ | ¨ | ´ | × |
| C_ | { | A | B | C | D | E | F | G | H | I | SHY | ô | ö | ò | ó | õ |
| D_ | } | J | K | L | M | N | O | P | Q | R | ¹ | û | ü | ù | ú | ÿ |
| E_ | \ | ÷ | S | T | U | V | W | X | Y | Z | ² | Ô | Ö | Ò | Ó | Õ |
| F_ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ³ | Û | Ü | Ù | Ú | APC |
Code page 500 (international)
Code page 037 with the seven differences below: the common punctuation moves.
| Byte | 500 | 037 |
|---|---|---|
4A | [ | ¢ |
4F | ! | | |
5A | ] | ! |
5F | ^ | ¬ |
B0 | ¢ | ^ |
BA | ¬ | [ |
BB | | | ] |
Code page 1047 (open systems Latin-1)
Code page 037 with six differences, so that the square brackets and circumflex are
where C programs on z/OS Unix expect them. Some z/OS conversions also swap NL
(15) and LF (25); the explorer treats both as line
endings.
| Byte | 1047 | 037 |
|---|---|---|
5F | ^ | ¬ |
AD | [ | Ý |
B0 | ¬ | ^ |
BA | Ý | [ |
BB | ¨ | ] |
BD | ] | ¨ |
National variants
These are code page 037 with national letters in place of some punctuation. Each row lists every byte that differs from 037, as byte and character.
| Code page | Differences from 037 |
|---|---|
| 273 (Germany, Austria) | 43 {, 4A Ä, 4F !, 59 ~, 5A Ü, 5F ^, 63 [, 6A ö, 7C §, A1 ß, B0 ¢, B5 @, BA ¬, BB |, C0 ä, CC ¦, D0 ü, DC }, E0 Ö, EC \, FC ] |
| 277 (Denmark, Norway) | 47 }, 4A #, 4F !, 5A ¤, 5B Å, 5F ^, 67 $, 6A ø, 70 ¦, 7B Æ, 7C Ø, 80 @, 9C {, 9E [, 9F ], A1 ü, B0 ¢, BA ¬, BB |, C0 æ, D0 å, DC ~ |
| 278 (Finland, Sweden) | 43 {, 47 }, 4A §, 4F !, 51 `, 5A ¤, 5B Å, 5F ^, 63 #, 67 $, 6A ö, 79 é, 7B Ä, 7C Ö, 9F ], A1 ü, B0 ¢, B5 [, BA ¬, BB |, C0 ä, CC ¦, D0 å, DC ~, EC @ |
| 280 (Italy) | 44 {, 48 \, 4A °, 4F !, 51 ], 54 }, 58 ~, 5A é, 5F ^, 6A ò, 79 ù, 7B £, 7C §, 90 [, A1 ì, B0 ¢, B1 #, B5 @, BA ¬, BB |, C0 à, CD ¦, D0 è, DD `, E0 ç |
| 284 (Spain, Latin America) | 49 ¦, 4A [, 5A ], 5B $, 69 #, 6A ñ, 7B Ñ, A1 ¨, B0 ¢, BA ^, BB !, BD ~ |
| 285 (United Kingdom) | 4A $, 4F |, 5A !, 5B £, 5F ¬, B0 ¢, B1 [, BA ^, BC ¯ |
| 297 (France) | 44 @, 48 \, 4A °, 4F !, 51 {, 54 }, 5A §, 5F ^, 6A ù, 79 µ, 7B £, 7C à, 90 [, A0 `, A1 ¨, B0 ¢, B1 #, B5 ], BA ¬, BB |, BD ~, C0 é, D0 è, DD ¦, E0 ç |
| 871 (Iceland) | 4A þ, 4F !, 5A Æ, 5B $, 5F Ö, 79 ð, 7C Ð, 8C `, 8E {, 9C }, 9E ], A1 ö, AC @, AE [, B0 ¢, BA ¬, BB |, BE \, C0 Þ, CC ~, D0 æ, E0 ´, EC ^ |
IBM publishes the tables of its code pages as CCSIDs. Other EBCDIC code pages, such as 420 (Arabic), 424 (Hebrew), 870 (Latin-2), 875 (Greek) and 1025 (Cyrillic), are not read by the explorer.
Lines
A line is the bytes up to a line ending. Each character is one byte, so counts of characters and bytes are the same. Records of fixed length without line endings read as one long line.
Line endings
| Name | Bytes | Notes |
|---|---|---|
| NL (new line) | 15 | the usual line end on mainframes; U+0085 in code page 037 |
| LF (line feed) | 25 | U+000A in code page 037 |
| CR LF | 0D 25 | |
| CR | 0D |
End of the file
The text simply stops at the end of the file. EBCDIC text has no end-of-file mark of its own, but trailing NUL
bytes show as Zero padding, and a trailing 1A as an End-of-file mark, as in other text.
Problems
| Problem | Meaning |
|---|---|
| NUL character | a 00 byte in the text |
| control character | a byte that maps to a control other than tab, form feed and the line endings |
| mixed line endings | more than one kind of line ending |
| zero padding | NUL bytes after the text |
Telling it apart
There is no mark or signature. The explorer tries this format after UTF-8, UTF-16, UTF-32 and GB18030, and before the legacy code pages. It takes a file when, in the first 64 KB:
- the file is at least 16 bytes long;
- the space byte
40makes up at least one byte in twenty; - the bytes of the space, the EBCDIC letters and the digits together make up at least seven in ten;
- bytes in the ASCII letter ranges (
41–5A,61–7A) are at most one in five.
Code page 037 is assumed, unless the square brackets are at AD and
BD rather than BA and BB, which point to 1047.
National pages cannot be told apart from their bytes; the explorer shows the file in
each of them (037, 500, 1047, 273, 277, 278, 280, 284, 285, 297 and 871) so that a
reader can pick.
Variants
- UTF-8 text – one to four bytes a character, ASCII unchanged
- UTF-16LE text – two or four bytes a character, low byte first
- UTF-16BE text – two or four bytes a character, high byte first
- UTF-32LE text – four bytes a character, low byte first
- UTF-32BE text – four bytes a character, high byte first
- Legacy code page text – a pre-Unicode code page that the file does not name
- UTF-7 text – Unicode as pure ASCII, with Base64 runs
- ISO-2022 and HZ text – 7-bit Japanese, Korean and Chinese with escape sequences
- GB18030 text – China’s national encoding, one, two or four bytes a character
- EBCDIC text – IBM mainframe text, not based on ASCII
Links
Software
- iconv – command that converts EBCDIC files to UTF-8, with a code page chosen by name (macOS, Linux)
Reference
- Unicode’s mapping files – code page 037 and others byte by byte