日本-日本語
日本HPホーム 製品 & サービス サポート & ドライバー ソリューション ご購入方法
≫  お問い合わせ

製品とサービス >  ソフトウェアとOS >  OpenVMS >  マニュアル

OpenVMS マニュアル


 

OpenVMS ドキュメント
ライブラリ

タイトル
目次
まえがき
リファレンス・セクション
   ≫ライブラリ関数一覧
索引
PDF
OpenVMS ホーム

HP OpenVMS
HP C ランタイム・ライブラリ・リファレンス・マニュアル (下巻)


目次 索引




文字クラスの定義に使用されます。この関数から返される値は, iswctype関数の呼び出しで使用されます。

形式

#include <wctype.h> (ISO C)

#include <wchar.h> (XPG4)

wctype_t wctype (const char *char_class);


引数



char_class

有効な文字クラス名へのポインタ。

説明

wctype関数は,現在のロケールに対して定義されている有効な文字クラスを, wctype_t型のオブジェクトに変換します。以下の文字クラスは,すべてのロケールに対して定義されています。

alnum        cntrl        lower        space 
alpha        digit        print        upper 
blank        graph        punct        xdigit 

現在のロケールの LC_CTYPE カテゴリに,その他の文字クラスが定義されていることもあります。

iswctypeも参照してください。


戻り値

x iswctype 関数の呼び出しに使用できる wctype_t 型のオブジェクト。
0 文字クラス名が現在のロケールに対して有効ではありません。


#include <locale.h> 
#include <wchar.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <string.h> 
#include <ctype.h> 
 
 
/* This test will set up a number of character class using wctype() */ 
/* and then verify whether calls to iswctype() using these classes  */ 
/* produce the same results as calls to the is**** routines.        */ 
 
main() 
{ 
 
    wchar_t w_char; 
    wctype_t ret_val; 
 
    char *character = "A"; 
 
    /* Convert character to wide character format - w_char */ 
 
    if (mbtowc(&w_char, character, 1) == -1) { 
        perror("mbtowc"); 
        exit(EXIT_FAILURE); 
    } 
 
    /* Check if results from iswalnum() matches check on */ 
    /* alnum character class                             */ 
 
    if ((iswalnum((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("alnum")))) 
        printf("[%C] is a member of the character class alnum\n", w_char); 
 else 
    printf("[%C] is not a member of the character class alnum\n", w_char); 
 
    /* Check if results from iswalpha() matches check on */ 
    /* alpha character class                             */ 
 
    if ((iswalpha((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("alpha")))) 
      printf("[%C] is a member of the character class alpha\n", w_char); 
    else 
     printf("[%C] is not a member of the character class alpha\n", w_char); 
 
    /* Check if results from iswcntrl() matches check on */ 
    /* cntrl character class                             */ 
 
    if ((iswcntrl((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("cntrl")))) 
        printf("[%C] is a member of the character class cntrl\n", w_char); 
    else 
     printf("[%C] is not a member of the character class cntrl\n", w_char); 
 
    /* Check if results from iswdigit() matches check on */ 
    /* digit character class                             */ 
 
    if ((iswdigit((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("digit")))) 
        printf("[%C] is a member of the character class digit\n", w_char); 
    else 
     printf("[%C] is not a member of the character class digit\n", w_char); 
 
    /* Check if results from iswgraph() matches check on */ 
    /* graph character class                             */ 
 
    if ((iswgraph((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("graph")))) 
        printf("[%C] is a member of the character class graph\n", w_char); 
    else 
     printf("[%C] is not a member of the character class graph\n", w_char); 
 
    /* Check if results from iswlower() matches check on */ 
    /* lower character class                             */ 
 
    if ((iswlower((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("lower")))) 
        printf("[%C] is a member of the character class lower\n", w_char); 
    else 
     printf("[%C] is not a member of the character class lower\n", w_char); 
 
    /* Check if results from iswprint() matches check on */ 
    /* print character class                             */ 
 
    if ((iswprint((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("print")))) 
        printf("[%C] is a member of the character class print\n", w_char); 
    else 
     printf("[%C] is not a member of the character class print\n", w_char); 
 
    /* Check if results from iswpunct() matches check on */ 
    /* punct character class                             */ 
 
    if ((iswpunct((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("punct")))) 
        printf("[%C] is a member of the character class punct\n", w_char); 
    else 
     printf("[%C] is not a member of the character class punct\n", w_char); 
 
    /* Check if results from iswspace() matches check on */ 
    /* space character class                             */ 
 
    if ((iswspace((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("space")))) 
        printf("[%C] is a member of the character class space\n", w_char); 
    else 
    printf("[%C] is not a member of the character class space\n", w_char); 
 
    /* Check if results from iswupper() matches check on */ 
    /* upper character class                             */ 
 
    if ((iswupper((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("upper")))) 
        printf("[%C] is a member of the character class upper\n", w_char); 
    else 
    printf("[%C] is not a member of the character class upper\n", w_char); 
 
    /* Check if results from iswxdigit() matches check on */ 
    /* xdigit character class                             */ 
 
    if ((iswxdigit((wint_t) w_char)) && 
        (iswctype((wint_t) w_char, wctype("xdigit")))) 
        printf("[%C] is a member of the character class xdigit\n", w_char); 
    else 
     printf("[%C] is not a member of the character class xdigit\n", w_char); 
 
} 

この例のプログラムを実行すると,次の結果が生成されます。

[A] is a member of the character class alnum 
[A] is a member of the character class alpha 
[A] is not a member of the character class cntrl 
[A] is not a member of the character class digit 
[A] is a member of the character class graph 
[A] is not a member of the character class lower 
[A] is a member of the character class print 
[A] is not a member of the character class punct 
[A] is not a member of the character class space 
[A] is a member of the character class upper 
[A] is a member of the character class xdigit 


目次 索引

印刷用画面へ
プライバシー 本サイト利用時の合意事項 ウェブマスターに連絡