XLATE - translate one character code to another.
Alternate Entry Name: .XLATE
Usage:
B:
xlate( outstr, outpos, instr, inpos, table, outlen
[, outype, intype, inlen, fill] );
C:
void xlate(void *outstr, int outpos,
const void *instr, int inpos,
void *table, int outlen [, int outype,
int intype, int inlen, int fill] );
Where:
- outstr
- is a pointer to the output string.
- outpos
- is a character offset into "outstr" giving the
leftmost character affected. The offset of the initial
character of "outstr" is zero, the offset of
the next character is one, and so on.
- instr
- is a pointer to the input string.
- inpos
- is a character offset into "instr" indicating
the first character to be translated.
- table
- is the translation table as described below.
- outlen
- is the number of characters to be placed in the output
string.
- outype
- is one of 4, 6, or 9, indicating the number of bits per
output character. If no "outype" is specified,
the default is 9 bits (ASCII characters).
- intype
- is one of 4, 6, or 9, indicating the number of bits per
input character. If no "intype" is specified,
the default is "outype".
- inlen
- is the number of input characters to be translated. If
"inlen" is not specified, the default is
"outlen".
- fill
- is the character used to pad the input string if
"outlen" is greater than "inlen". If
no "fill" is specified, the default is 040
octal, the ASCII blank.
Description:
XLATE copies the input string to the output, and translates it
according to the table of nine-bit characters specified by
"table". If the input string is shorter than the output
string, the input string is logically extended on the right with
the "fill" character. Note that the "fill"
character is translated.
Translation is performed as follows. An input character is
obtained. The value of this character is used as an index into
"table" (as in "char(table, c)" ), and the
value obtained is placed into the output string. This process is
repeated for each character in the input string, including any
"fill" characters on the end.
Examples:
/* Translate 4 bit hex to ASCII. */
table {"0123456789abcdef"};
...
extrn table;
xlate( outstr, 0, instr, 0, table, count, 9, 4 );
Copyright © 1996, Thinkage Ltd.