iswpunct
函数 <cwctype>
int iswpunct (wint_t c);
检查宽字符是否为标点符号
检查c是否为标点符号。
标点符号是指在特定的语言环境中被视为标点符号的字符。
这些字符具有图形表示(如
iswgraph),
但必须是非字母数字的(如
iswalnum)。
该函数是
ispunct
(<
cctype>)等效的宽字符版:
如果c通过
wctob
转换为
ispunct为true的字符,
则该函数始终将其视为标点字符(除了L' '以外的某些特定于区域的可打印空白字符)。
在c++中,对于所有字符类型,该函数的特定于区域的模板版本(ispunct)在头文件<locale>中。
☲ 参数
c
要检查的宽字符,转换为wint_t或
WEOF。
wint_t是整型。
☉ 返回值
如果c确实是一个标点符号,返回一个不等于零的值(如,true)。否则零(即false)。
☣ 示例
/* iswpunct example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
int i=0;
int cx=0;
wchar_t str[] = L"Hello, welcome!";
while (str[i])
{
if (iswpunct(str[i])) cx++;
i++;
}
wprintf (L"The sentence contains %d punctuation characters.\n", cx);
return 0;
}
|
输出:
The sentence contains 2 puntuation characters.
🍄 另请参阅
ispunct |
检查字符是否是标点符号(function ) |
iswgraph |
检查宽字符是否为图形形式(function ) |
iswcntrl |
检查宽字符是否为控制字符(function ) |
ispunct(locale) |
使用区域设置检查字符是否标点符号(function template ) |