TL;DR;
Punch card code is not binary but a collection of n out of m encodings.
Long Story
Yes, really a long story, so I'll only cover the main line from Hollerith to EBCDIC. There are many sidelines for special equipment, situations and as used by different manufacturers. Some covering up to 7 holes but all mostly compatible in the basic Numeric/Alpha region ... a bit like the various ISO 646 encodings :)
Punch card encoding is essentially combinatoric and based upon decimal - with one hole per number - as it did grow out of numerical only - and based on the way cards were seen:
Example:
COL 1234...
ROW ,-------~
12 |
11 |
(1)0 |0000... (Row zero is called 10 when it's about Alpha)
1 |1111...
2 |2222...
3 |3333...
4 |4444...
5 |5555...
6 |6666...
7 |7777...
8 |8888...
9 |9999...
'-------~
Notation: Punched characters are described as their row numbers connected by hyphens, like 12-1 marks an A
.
Numbers
Numbers use a one out of ten encoding. A number gets only one hole within a column. Rows 11 and 12 were used for -
and +
as sign.
(Upper Case) Letters
To add alpha, a two out of twelve encoding was used (or more precisely, one out of three plus one out of nine) Each of the 26 basic (English) characters got one 'group' hole in row 10..12, called 'Zone', and a 'number' hole in 1..9. 3 x 9 = 27 combinations, a pleasant fit to hold 26 character, isn't it?
- A..I got a hole in 12 plus one in 1..9
- J..R one in 11 plus another in 1..9, while
- S..Z had it in 10 (0) and 2..9.
The surplus combination (27 positions minus 26 letters) was assigned to 10-1 to avoid having two adjacent holes (*1).
RETRO
,-------~
12 | X
11 |X XXX
10 |
1 |
2 |
3 |
4 |
5 | X
6 | X
7 |
8 | X
9 |X X
'-------~
Punctuation
To add punctuation, the scheme was repeated using a three hole encoding. This time a hole in row 8 marks all punctuation, with characters as none or one out of three (10..12) plus one out of six in row 2 to 7, allowing up to 24 symbols.
*C+=1
,-------~
12 | XX
11 |X
10 |
1 | X
2 |
3 | X
4 |X
5 |
6 | XX
7 |
8 |X XX
9 |
'-------~
Lower Case Letters
EBCDIC finally added lower case letters by again using 3 holes, but this time two in the group section (10..12), making it a two out of three plus one out of nine (1..9). Except for the added group hole, the encoding was exactly like the uppercase, so
- a..i like A..I plus 10 (0)
- j..r like J..R plus 12
- s..z like S..Z plus 11
Retro
,-------~
12 | XXXX
11 |X XXX
10 | X
1 |
2 |
3 |
4 |
5 | X
6 | X
7 |
8 | X
9 |X X
'-------~
Control Characters
Control characters were filled in with EBCDIC as well, much like punctuation, but this time with an additional hole in row 9 and using a one out of three (10..12) plus one out of seven (1..7) producing 28 possible control codes.
Oddities
Two control characters (NUL and DS) use a five hole combination, while SPACE means no hole at all (and differs form BLANK). 12 alone has been redefined to &
as +
wandered over to 12-8-6
S
P
AN
CUD
&-/+ELS
,--------~
12 |X X X
11 | X X
10 | X XX
1 | X XX
2 |
3 |
4 |
5 |
6 | X
7 |
8 | X XX
9 | XX
'-------~
Bottom line
Although a hole might be seen as a binary values, punch card holes are not, but represent their row.
*1 - It was later used for the slash (/
).