home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ACTLIB10.ZIP / STRINGS.ZIP / CHCASE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-14  |  1.4 KB  |  75 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #include <ctype.h>
  4. #include "strings.h"
  5.  
  6. /***
  7.  *  Function    :  chcase
  8.  *
  9.  *  Description :  change case of a 2-byte character.
  10.  *              All special characters are translated (éèà...)
  11.  *
  12.  *  Parameters  :  in   char      car      char to translate
  13.  *                 in   casetype  type     UPPER/LOWER
  14.  *                                        
  15.  *  Value       :  type = { UPPER, LOWER }
  16.  *
  17.  *  Decisions   :  If character > 255, no change made.
  18.  *
  19.  *  Return      :  code of char translated
  20.  *
  21.  *  OS/Compiler :  All
  22.  ***/
  23.  
  24. int chcase( int car, casetype type )
  25.  
  26. { if ( car > 255 ) return car;
  27.  
  28.   switch( car )
  29.     {
  30.       case 'à':
  31.       case 'â':
  32.       case 'ä':
  33.         case 'å':
  34.       case 'Ä':
  35.       case 'Å':
  36.       case 'ª':
  37.       case 'á': car = 'a'; break;
  38.  
  39.       case 'é':
  40.       case 'è':
  41.       case 'ê':
  42.       case 'ë':
  43.       case 'É': car = 'e'; break;
  44.  
  45.       case 'ï':
  46.       case 'î':
  47.       case 'ì':
  48.       case 'í': car = 'i'; break;
  49.  
  50.       case 'ô':
  51.       case 'ö':
  52.         case 'ò':
  53.       case 'ó':
  54.       case 'Ö':
  55.       case 'º': car = 'o'; break;
  56.  
  57.       case 'û':
  58.       case 'ü':
  59.       case 'Ü':
  60.       case 'ù':
  61.       case 'ú': car = 'u'; break;
  62.  
  63.       case 'ÿ': car = 'y'; break;
  64.  
  65.       case 'ç':
  66.       case 'Ç': car = 'c'; break;
  67.  
  68.       case 'ñ':
  69.       case 'Ñ': car = 'n'; break;
  70.     }
  71.  
  72.   if ( type == UPPER ) return toupper(car);
  73.                   else return tolower(car);
  74. }
  75.