std::isxdigit

Header: <cctype>

Checks if the given character is a hexadecimal numeric character (0123456789ABCDEFabcdef).

# Declarations

int isxdigit( int ch );

# Parameters

# Return value

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

# Notes

std::isdigit and std::isxdigit are the only standard narrow character classification functions that are not affected by the currently installed C locale. although some implementations (e.g. Microsoft in 1252 codepage) may classify additional single-byte characters as digits.

Like all other functions from , the behavior of std::isxdigit 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:

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:

# Example

#include <cctype>
#include <climits>
#include <iostream>
 
int main()
{
    for (int c = 0; UCHAR_MAX >= c; ++c)
        if (isxdigit(c))
            std::cout << static_cast<char>(c);
    std::cout << '\n';
}

# See also