📅  最后修改于: 2020-09-25 14:33:55             🧑  作者: Mango
wctype() 函数在
wctype_t wctype(const char* str);
wctype() 函数将C 字符串 str
作为其参数,并返回类型wctype_t的值,该值用于对宽字符进行分类。
Value of str | Equivalent function |
---|---|
alnum | iswalnum |
alpha | iswalpha |
blank | iswblank |
cntrl | iswcntrl |
digit | iswdigit |
graph | iswgraph |
lower | iswlower |
iswprint | |
punct | iswpunct |
space | iswspace |
xdigit | iswxdigit |
upper | iswupper |
#include
#include
#include
using namespace std;
int main()
{
setlocale(LC_ALL, "en_US.UTF-8");
wchar_t wc = L'\u00b5';
if (iswctype(wc, wctype("digit")))
wcout << wc << L" is a digit";
else if (iswctype(wc, wctype("alpha")))
wcout << wc << L" is an alphabet";
else
wcout << wc << L" is neither an alphabet nor a digit";
return 0;
}
运行该程序时,输出为:
µ is an alphabet