home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_01 / 3n01022a < prev    next >
Text File  |  1991-12-05  |  894b  |  21 lines

  1.  
  2. /* The parameter in the following procedure is S, which is the string
  3.    we want to translate.  We return the translated characters in S. */
  4. translation (S,main_table,sequential_table)
  5.   unsigned char S[];       /* NB: it won't be unsigned by default */
  6.   char main_table[];       /* the main 256-byte collation-lookup table */
  7.   char sequential_table[];      /* list of 2-byte character codes (if any) */
  8.  {
  9.    unsigned int i,j,collation_code;
  10.  
  11.    for (i=0; S[i]!='\0'; ++i) {
  12.      collation_code=main_table[S[i]];
  13.      for (j=0; sequential_table[j]!='\0'; j+=3) {
  14.        if (S[i]==sequential_table[j] && S[i+1]==sequential_table[j_1]) {
  15.          S[i]=sequential_table[j+2];
  16.          break; } }
  17. /* Note: if language is German, put a line here for 
  18.    translating the eszet (usually code 225) to SS.  Note that
  19.    results in a size increase. */
  20.    S[i]=collation_code; } }
  21.