A 2-to-1 translation takes a two character combination, and translates it to one character.
Note: The strings involved are not actually changed. The change occurs internally for the string comparison and is then discarded.
To define 2-to-1 translations starting with a certain character, the order table entry for the starting character is used to store three things: 1) the order number is stored in the upper byte for use when the character occurs, but not as part of a two character combination, 2) the value 64 is stored in the lower byte to indicate that this character is the first character of one or more 2-to-1 translations, 3) an index into the special case table is stored in the lower byte.
The index into the special case table points to a list of two character combinations that all start with the same first character. The first entry in the list gives the number of two character combinations in the list. The remaining entries give the second character of each two character combination and the order number to use in place of the combination. The second character is given in the upper byte and the order number is given in the lower byte.
Note: The first character was given in the order table and need not be repeated in the special case table. Only the second character of each combination is given in the special case table.
For example, we might want to consider "DX" to be a single character with order number 4 and "DY" to be a single character with order number 3. For all other occurrences of the letter "D" we want "D" to have order number 2. For our example,
10 INTEGER A(0:259)
50 A(NUM("D"))=SHIFT(2,-8)+64+0
100 A(256)=0+3
110 A(257)=2
120 A(258)=SHIFT(NUM("X"),-8) + 4
130 A(259)=SHIFT(NUM("Y"),-8) + 3
Line 50 is the order table entry for the letter "D". Order number 2 will be used for "D" unless it is "DX" or "DY". The value 64 indicates one or more 2-to-1 translations exist that start with the letter "D". The value 0 is the index into the special case table.
Line 100 is the length of the special case table. Previously in our example, we had set it to zero, but we are now adding three entries to the special case table.
In line 110, A(257) is at index 0 in the special case table. This is the start of our list of two character combinations beginning with "D". Since we have two, "DX" and "DY", we set A(257) to two.
Lines 120 and 130 define "DX" and "DY" to have order numbers 4 and 3. Now the following will both be true:
"DY" <"DX" - because 3 <4
"DZ" <"DX" - because 2 < 4 ("D" < "DX").