jisx0201.h
Upload User: yingmei828
Upload Date: 2007-01-01
Package Size: 1646k
Code Size: 1k
Development Platform:

Unix_Linux

  1. /*
  2.  * JISX0201.1976-0
  3.  */
  4. static int
  5. jisx0201_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
  6. {
  7.   unsigned char c = *s;
  8.   if (c < 0x80) {
  9.     if (c == 0x5c)
  10.       *pwc = (wchar_t) 0x00a5;
  11.     else if (c == 0x7e)
  12.       *pwc = (wchar_t) 0x203e;
  13.     else
  14.       *pwc = (wchar_t) c;
  15.     return 1;
  16.   } else {
  17.     if (c >= 0xa1 && c < 0xe0) {
  18.       *pwc = (wchar_t) c + 0xfec0;
  19.       return 1;
  20.     }
  21.   }
  22.   return RET_ILSEQ;
  23. }
  24. static int
  25. jisx0201_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
  26. {
  27.   if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
  28.     *r = wc;
  29.     return 1;
  30.   }
  31.   if (wc == 0x00a5) {
  32.     *r = 0x5c;
  33.     return 1;
  34.   }
  35.   if (wc == 0x203e) {
  36.     *r = 0x7e;
  37.     return 1;
  38.   }
  39.   if (wc >= 0xff61 && wc < 0xffa0) {
  40.     *r = wc - 0xfec0;
  41.     return 1;
  42.   }
  43.   return RET_ILSEQ;
  44. }