home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / DUTCH_FN.ZIP / TRANSLAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-10  |  2.6 KB  |  84 lines

  1. /*********
  2. *
  3. * TRANSLATE.C
  4.  
  5. *   Author : Jean-Pierre van Melis
  6. * Compiled : with Microsoft C 5.1
  7. *   Object : can only be used in conjunction with Clipper summer '87
  8.  
  9. *  Syntax: TRANSLATE( <expC> )
  10. *  Return: All foreign characters are replaced by there ASCII-counterpart.
  11. *
  12. *          ü û ù ú                replacement : u
  13. *          â ä à å á              replacement : a
  14. *
  15. *
  16. *          INPUT                  RETURN
  17. *          ---------------------- ----------------------------------
  18. *           "garçon"              "garcon"
  19. *           "tête"                "tete"
  20. *           "wilde zeeën"         "wilde zeeen" 
  21. *
  22. *********/
  23.  
  24. #include "jplib.h"
  25.  
  26. static byte convert[40] =
  27. { 'C','u','e','a','a','a','a','c','e','e','e','i','i','i','A','A','E','æ','Æ'
  28.  ,'o','o','o','u','u','Y','O','U','¢','£','¥','₧','ƒ','a','i','o','u'
  29.  ,'n','N','a','o'};
  30.  
  31. /*
  32.    Ç   ü   é   â   ä   à   å   ç   ê   ë   è   ï   î   ì   Ä   Å   É   æ   Æ
  33.    ô   ö   ò   û   ù   ÿ   Ö   Ü   ¢   £   ¥   ₧   ƒ   á   í   ó   ú
  34.    ñ   Ñ   ª   º
  35. */
  36.  
  37. CLIPPER translate()
  38.  
  39. {
  40.  
  41.    byte *par;                                      /* pointer to input */
  42.    byte *retstr;                                   /* pointer to output */
  43.  
  44.    quant leng;                                     /* leng of string */
  45.    quant n1;                                       /* offset input */
  46.    quant n2;                                       /* offset output */
  47.  
  48.    Boolean error;
  49.  
  50.    error = TRUE;
  51.  
  52.    if(PCOUNT == 1 && ISCHAR(1))
  53.    {
  54.       par    = _parc(1);                           /* receive pointer from clipper */
  55.       leng   = (quant) _parclen(1);                /* receive leng from clipper */
  56.  
  57.       retstr = _exmgrab(leng+1);                   /* Allocate memory */
  58.  
  59.       if(retstr)                                   /* Enough memory available */
  60.       {
  61.          error = FALSE;                            /* No errors */
  62.          n2    = 0;                                /* point to first character */
  63.  
  64.          for(n1 = 0; n1 < leng; n1++)              /* parse input till end of input*/
  65.          {
  66.             if((par[n1] >127) && (par[n1] < 168))
  67.                retstr[n2++] = convert[par[n1]-128];
  68.             else
  69.                retstr[n2++] = par[n1];
  70.          }
  71.  
  72.          retstr[n2] = NULLC;                       /* terminate with null */
  73.       }
  74.    }
  75.    if(error)
  76.       _retc(NULLS);                                /* return null string */
  77.    else
  78.    {
  79.       _retclen(retstr, leng);                      /* return string with length */
  80.       _exmback(retstr, leng+1);                    /* deallocate memory */
  81.    }
  82.    return;
  83. }
  84.