wctype() — 文字特性種別のハンドルの取得

フォーマット

#include <wctype.h>
wctype_t wctype(const char *property);

言語レベル: XPG4

スレッド・セーフ: はい。

説明

wctype() 関数は、有効な文字クラス名に対して定義されます。 property は、総称文字クラスを識別する ストリングです。次の文字クラス名は、すべてのロケールで定義されます (alnumalphablankcntrldigitgraphlowerprintpunctspaceupperxdigit)。この関数は、wctype_t 型の値を戻します。この値は、iswctype() 関数の呼び出しに対する 2 番目の引数として使用できます。

wctype() 関数は、プログラムのロケール (カテゴリー LC_CTYPE) の 文字型情報によって定義されたコード化文字セットの規則に 従って wctype_t の値を判別します。wctype() によって戻された値は、 カテゴリー LC_CTYPE を変更する setlocale() を呼び出すまで有効です。

戻り値

指定された特性名が無効の場合、wctype() 関数はゼロを戻します。 そうでない場合には、iswctype() の呼び出しに使用できる型 wctype_t の値を 戻します。

wctype() の使用例

#include <wchar.h>
 
#define   UPPER_LIMIT   0xFF
      int   main(void)
      {
         int   wc;
         for   (wc   =   0;   wc  <=   UPPER_LIMIT;   wc++)   {
            printf("%#4x ",   wc);
            printf("%c",   iswctype(wc,   wctype("print"))  ?   wc    : "
");
            printf("%s",   iswctype(wc,   wctype("alnum"))  ?   "AN"  : "
");
            printf("%s",   iswctype(wc,   wctype("alpha"))  ?   "A"   : "
");
            printf("%s",   iswctype(wc,   wctype("blank"))  ?   "B"   : "
");
            printf("%s",   iswctype(wc,   wctype("cntrl"))  ?   "C"   : "
");
            printf("%s",   iswctype(wc,   wctype("digit"))  ?   "D"   : "
");
            printf("%s",   iswctype(wc,   wctype("graph"))  ?   "G"   : "
");
            printf("%s",   iswctype(wc,   wctype("lower"))  ?   "L"   : "
");
            printf("%s",   iswctype(wc,   wctype("punct"))  ?   "PU"  : "
");
            printf("%s",   iswctype(wc,   wctype("space"))  ?   "S"   : "
");
            printf("%s",   iswctype(wc,   wctype("print"))  ?   "PR"  : "
");
            printf("%s",   iswctype(wc,   wctype("upper"))  ?   "U"   : "
");
            printf("%s",   iswctype(wc,   wctype("xdigit")) ?   "X"   : "
");
            putchar('¥n');
         }
         return   0;
        /***********************************************************************
            The   output   should   be   similar   to   :
             :
            0x1f              C
            0x20           B                   S    PR
            0x21   !                  G       PU      PR
            0x22   "                  G       PU      PR
            0x23   #                  G       PU      PR
            0x24   $                  G       PU      PR
            0x25   %                  G       PU      PR
            0x26   &                  G       PU      PR
            0x27   '                  G       PU      PR
            0x28   (                  G       PU      PR
            0x29   )                  G       PU      PR
            0x2a   *                  G       PU      PR
            0x2b   +                  G       PU      PR
            0x2c   ,                   G       PU      PR
            0x2d   -                  G       PU      PR
            0x2e   .                   G       PU      PR
            0x2f   /                   G       PU      PR
            0x30   0   AN            D    G             PR      X
            0x31   1   AN            D    G             PR      X
            0x32   2   AN            D    G             PR      X
            0x33   3   AN            D    G             PR      X
            0x34   4   AN            D    G             PR      X
            0x35   5   AN            D    G             PR      X
             :
         ***********************************************************************
      }

関連情報



[ ページのトップ | 前ページ | 次ページ | 目次 | 索引 ]