📜  C++ iswcntrl()

📅  最后修改于: 2020-09-25 10:21:07             🧑  作者: Mango

C++中的iswcntrl() 函数检查给定的宽字符是否为控制字符 。

iswcntrl() 函数在头文件中定义。

iswcntrl()原型

int iswcntrl(wint_t ch);

iswcntrl() 函数检查ch是否为控制字符 。默认情况下,从0x00到0x1F的和0x7F的代码字符被认为是控制字符。

iswcntrl()参数

iswcntrl()返回值

示例:iswcntrl() 函数如何工作?

#include 
#include 
using namespace std;

int main()
{
    wchar_t ch1 = L'\u000c';// unicode for form feed
    wchar_t ch2 = L'\u03a3';// unicode for Σ
    
    cout << hex << showbase << boolalpha << "iswcntrl(" << (wint_t)ch1 << ") returned " << (bool)iswcntrl(ch1) << endl;
    cout << hex << showbase << boolalpha << "iswcntrl(" << (wint_t)ch2 << ") returned " << (bool)iswcntrl(ch2) << endl;

    return 0;
}

运行该程序时,输出为:

iswcntrl(0xc) returned true
iswcntrl(0x3a3) returned false