C語言wctype頭文件(wctype.h)中wctype函數的用法及代碼示例。
用法:
wctype_t wctype (const char* property);
返回字符屬性
特定語言環境可以接受多個類別以對其字符進行分類。所有語言環境至少都識別以下類別:
字符串作為屬性 | 描述 | 等效函數 |
---|---|---|
"alnum" | 字母數字字符 | iswalnum |
"alpha" | 字母字符 | iswalpha |
"blank" | 空白字符 | iswblank |
"cntrl" | 控製字符 | iswcntrl |
"digit" | 十進製數字字符 | iswdigit |
"graph" | 具有圖形表示的字符 | iswgraph |
"lower" | 小寫字母字符 | iswlower |
"print" | 可打印字符 | iswprint |
"punct" | 標點符號 | iswpunct |
"space" | 空格字符 | iswspace |
"upper" | 大寫字母字符 | iswupper |
"xdigit" | 十六進製數字字符 | iswxdigit |
此函數返回的值取決於LC_CTYPE locale選擇的類別。
參數
- property
- 標識字符類別的字符串(請參見上文)。
返回值
類型值wctype_t識別特定的字符類別。此值為locale-dependent。
示例
/* wctype example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
int i=0;
wchar_t str[] = L"Test String.\n";
wchar_t c;
wctype_t check = wctype("lower");
wctrans_t trans = wctrans("toupper");
while (str[i])
{
c = str[i];
if (iswctype(c,check)) c = towctrans(c,trans);
putwchar (c);
i++;
}
return 0;
}
輸出:
TEST STRING. |
相關用法
- C語言 iswalnum用法及代碼示例
- C語言 iswalpha用法及代碼示例
- C語言 iswblank用法及代碼示例
- C語言 iswcntrl用法及代碼示例
- C語言 iswdigit用法及代碼示例
- C語言 iswgraph用法及代碼示例
- C語言 iswlower用法及代碼示例
- C語言 iswprint用法及代碼示例
- C語言 iswpunct用法及代碼示例
- C語言 iswspace用法及代碼示例
- C語言 iswupper用法及代碼示例
- C語言 iswxdigit用法及代碼示例
- C語言 towlower用法及代碼示例
- C語言 towupper用法及代碼示例
- C語言 iswctype用法及代碼示例
- C語言 towctrans用法及代碼示例
- C語言 wctrans用法及代碼示例
注:本文由純淨天空篩選整理自C標準庫大神的英文原創作品 C wctype function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。