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

  1.  
  2. /*** Listing #4
  3. */
  4. /***  vShftJis2Jis - Converts Shift JIS code to JIS.
  5. *
  6. *   purpose:    Converts a char Shift JIS code to its corresponding
  7. *               JIS code.
  8. *   parameters: pcShJis: Pointer to shift JIS code.
  9. *               pcJis  : Pointer to Jis code for return.
  10. *   return:     None
  11. *   modified:
  12. */
  13. void vShftJis2Jis (
  14.     DBC  *pcShJis,  /*  pointer to Shift JIS code                        */
  15.     DBC  *pcJis)    /*  pointer to JIS code for return       */
  16.     {
  17.     int c1, c2;
  18.     c1 = (*pcShJis++) & 0xff;
  19.     c2 = (*pcShJis) & 0xff;
  20.     if (c2 <= 0x9e)  {
  21.         c1 = (c1 <= 0x9f) ? (c1 - 0x71)*2+1 : (c1-0xb1)*2+1;
  22.         c2 -= 0x1f;
  23.         if (c2 >= 0x61)
  24.             c2--;
  25.     } else {
  26.         c1  = (c1 <= 0x9f) ? (c1-0x70)*2 : (c1-0xb0)*2;
  27.         c2 -= 0x7e;
  28.     }
  29.     pcJis[0] = c1;
  30.     pcJis[1] = c2;
  31. } /* vShftJis2Jis */
  32.  
  33.