std::isalnum(std::locale)(3)
π NAME π
okay bestie, welcome to the std::isalnum(std::locale) page from the C++ Standard Libary manual, section 3. That's the whole title-and-manual-name situation, folded in cute so we can get to the good stuff. β¨
πΈ Synopsis πΈ
Defined in header <locale>:
template< class CharT >
bool isalnum( CharT ch, const locale& loc );
This function checks whether the character you pass in is classified as an alphanumeric character by the given locale's std::ctype facet. It's giving "vibe check for alphanumeric-ness, but make it locale-aware" π
π¦ Parameters π¦
chβ characterlocβ locale
π Return value π
Returns true if the character is classified as alphanumeric, and false otherwise. Periodt. β¨
π§ Possible implementation π§
template<class CharT>
bool isalnum(CharT ch, const std::locale& loc)
{
return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::alnum, ch);
}
π Example π
This example demonstrates the use of isalnum() with different locales (OS-specific). The original page has the little // Run this code marker, so here's the code in all its glory:
#include <iostream>
#include <locale>
int main()
{
const wchar_t c = L'\u2135'; // mathematical symbol aleph
std::locale loc1("C");
std::cout << "isalnum('β΅', C locale) returned "
<< std::boolalpha << std::isalnum(c, loc1) << '\n';
std::locale loc2("en_US.UTF-8");
std::cout << "isalnum('β΅', Unicode locale) returned "
<< std::boolalpha << std::isalnum(c, loc2) << '\n';
}
β Possible output β
isalnum('β΅', C locale) returned false
isalnum('β΅', Unicode locale) returned true
π See also π
isalnumβ checks if a character is alphanumeric (function)iswalnumβ checks if a wide character is alphanumeric (function)
okay that's the page, bestie π«Ά. Shoutout to the source and version/date in the footer: http://cppreference.com, 2024.06.10. slay π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms