HTBasic Help
×
Menu
Index

1-to-2 Translation

 
A 1-to-2 translation takes a single character and translates it into two characters. This capability also includes intelligent handling of upper and lowercase. For example, if "E" is to be translated to "FG" then "Exyz" should be translated to "Fgxyz", while "EXYZ" should be translated to "FGXYZ".
 
Note: The strings involved are not actually changed. The change occurs internally for the string comparison and is then discarded.
 
To define 1-to-2 translations for a certain character, the order table entry for the character is used to store three things: 1) the first order number is stored in the upper byte, 2) the value 128 is stored in the lower byte to indicate a 1-to-2 translation, 3) an index into the special case table is stored in the lower byte.
 
The special case table entry contains the second order numbers for both upper and lowercase. The lower byte contains the lowercase order number, while the upper byte contains the uppercase order number. The uppercase order number is used if the initial character is uppercase and is not followed by a lowercase character.
 
For our example, if we want to use an order number of 5 for "F", 6 for "G", and 37 for "g", then:
 
10  INTEGER A(0:260)
60  A(NUM("E"))=SHIFT(5,-8)+128+3
100 A(256)=0+3+1
140 A(260)=SHIFT(6,-8) + 37
 
Line 100 is the length of the special case table. Previously in our example, we had set it to three, but we have now added one more entry to the special case table.
 
Line 60 is the order table entry for the letter "E" and line 140 is the special case entry for "E". In place of "E", two order numbers will be used, 5 and 37 for "Fg", or 5 and 6 for "FG". Now the following will all be true:
 
"E" > "FD"
"E" = "FG"
"E" < "FH"
"EXYZ" = "FGXYZ"
"Exyz" = "Fgxyz"