Namespaces
Variants
Actions

std::iscntrl

From cppreference.com
< cpp‎ | string‎ | byte
 
 
 
 
Defined in header <cctype>
int iscntrl( int ch );

Checks if the given character is a control character as classified by the currently installed C locale. In the default, "C" locale, the control characters are the characters with the codes 0x00-0x1F and 0x7F.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Contents

[edit] Parameters

ch - character to classify

[edit] Return value

Non-zero value if the character is a control character, zero otherwise.

[edit] Notes

Like all other functions from <cctype>, the behavior of std::iscntrl is undefined if the argument's value is neither representable as unsigned char nor equal to EOF. To use these functions safely with plain chars (or signed chars), the argument should first be converted to unsigned char:

bool my_iscntrl(char ch)
{
    return std::iscntrl(static_cast<unsigned char>(ch));
}

Similarly, they should not be directly used with standard algorithms when the iterator's value type is char or signed char. Instead, convert the value to unsigned char first:

int count_cntrls(const