std::iswalnum - cppreference.com
Namespaces
Variants

std::iswalnum

From cppreference.com
 
 
 
 
Defined in header <cwctype>
int iswalnum( std::wint_t ch );

Checks if the given wide character is an alphanumeric character, i.e. either a number (0123456789), an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), a lowercase letter (abcdefghijklmnopqrstuvwxyz) or any alphanumeric character specific to the current locale.

If the value of ch is neither representable as a wchar_t nor equal to the value of the macro WEOF, the behavior is undefined.

Parameters

ch - wide character

Return value

Non-zero value if the wide character is an alphanumeric character, zero otherwise.

Notes

ISO 30112 specifies which Unicode characters are included in the POSIX alnum category.

Example

#include <clocale>
#include <cwctype>
#include <iostream>

int main()
{
    wchar_t c = L'\u13ad'; // the Cherokee letter HA ('Ꭽ')

    std::cout << std::hex << std::showbase << std::boolalpha;
    std::cout << "in the default locale, iswalnum(" << (std::wint_t)c << ") = "
              << (bool)std::iswalnum(c) << '\n';

    std::setlocale(LC_ALL, "en_US.utf8");
    std::cout << "in Unicode locale, iswalnum(" << (std::wint_t)c << ") = "
              << (bool)std::iswalnum(c) << '\n';
}

Possible output:

in the default locale, iswalnum(0x13ad) = false
in Unicode locale, iswalnum(0x13ad) = true

See also

checks if a character is classified as alphanumeric by a locale
(function template) [edit]
checks if a character is alphanumeric
(function) [edit]
C documentation for iswalnum