std::iswalpha(3)
๐ธ std::iswalpha(3), but make it bestie-coded ๐ธ
So this is the std::iswalpha(3) page from the C++ Standard Libary manual โ yes, that spelling is in the header, and I'm folding the manual name in right here near the top like a little name tag, typo and all. No cap, it's a wide-character alphabet check. ๐
โจ NAME โจ
std::iswalpha - std::iswalpha. That's the name, bestie. She's literally named std::iswalpha and she's doing exactly what it says on the tin. ๐
๐ Synopsis ๐
Defined in header <cwctype>:
int iswalpha( std::wint_t ch );
Okay so what it does: checks if the given wide character is an alphabetic character, i.e. either an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), a lowercase letter (abcdefghijklmnopqrstuvwxyz) or any alphabetic character specific to the current locale. ๐โจ
๐จ Danger zone, bestie: if the value ofchis neither representable as awchar_tnor equal to the value of the macroWEOF, the behavior is undefined. Like, undefined undefined. Do not play with that. ๐
๐ Parameters ๐
chโ wide character. That's it. She's a wide character, your honor. ๐ซถ
๐ฅ Return value ๐ฅ
Non-zero value if the wide character is an alphabetic character, 0 otherwise. So truthy = alpha, 0 = not alpha. Simple, iconic, periodt. ๐
๐ฆ Notes ๐ฆ
ISO 30112 specifies which Unicode characters are include in POSIX alpha category. (Yes, "include" is the original wording โ I'm not fixing it, I'm just delivering the facts with a cute bow on top. ๐)
๐ Example ๐
// Run this code
#include <clocale>
#include <cwctype>
#include <iostream>
int main()
{
wchar_t c = L'\u0b83'; // Tamil sign Visarga ('เฎ')
std::cout << std::hex << std::showbase << std::boolalpha;
std::cout << "in the default locale, iswalpha(" << (std::wint_t)c
<< ") = "
<< (bool)std::iswalpha(c) << '\n';
std::setlocale(LC_ALL, "en_US.utf8");
std::cout << "in Unicode locale, iswalpha(" << (std::wint_t)c << ") = "
<< (bool)std::iswalpha(c) << '\n';
}
Possible output:
in the default locale, iswalpha(0xb83) = false
in Unicode locale, iswalpha(0xb83) = true
๐ See also ๐
isalpha(std::locale)โ checks if a character is classified as alphabetic by a locale (function template)isalphaโ checks if a character is alphabetic (function)- C documentation for
iswalpha
And then there's this giant ASCII values chart, and I'm keeping every single row because that's the assignment. It's giving chaos, but every value is here:
ASCII values characters iscntrl isprint isspace
isblank isgraph ispunct isalnum isalpha isupper islower isdigit
isxdigit decimal hexadecimal octal iswcntrl iswprint
iswspace iswblank iswgraph iswpunct iswalnum iswalpha iswupper iswlower
iswdigit iswxdigit 0โ8 \x0โ\x8 \0โ\10 control codes โ 0
0 0 0 0 0 0 0 0
0 0 0
(NUL, etc.) 9 \x9 \11
tab (\t) โ 0 0 โ 0 โ 0 0 0 0
0 0 0 0 0
whitespaces 10โ13 \xAโ\xD \12โ\15
(\n, \v, \f, โ 0 0 โ 0 0 0 0 0
0 0 0 0 0
\r) 14โ31 \xEโ\x1F \16โ\37 control
codes โ 0 0 0 0 0 0 0 0
0 0 0 0 32 \x20 \40 space
0 โ 0 โ 0 โ 0 0 0 0 0
0 0 0 0 33โ47 \x21โ\x2F \41โ\57
!"#$%&'()*+,-./ 0 โ 0 0 0 โ 0 โ 0 0
0 0 0 0 0 48โ57 \x30โ\x39 \60โ\71
0123456789 0 โ 0 0 0 โ 0 0 โ 0
0 0 0 โ 0 โ 0 58โ64 \x3Aโ\x40 \72โ\100
:;<=>?@ 0 โ 0 0 0 โ 0 โ 0 0
0 0 0 0 0 65โ70 \x41โ\x46 \101โ\106
ABCDEF 0 โ 0 0 0 โ 0 0 โ 0
โ 0 โ 0 0 0 โ 0 71โ90 \x47โ\x5A \107โ\132
GHIJKLMNOP 0 โ 0 0 0 โ 0 0 โ 0
โ 0 โ 0 0 0 0
QRSTUVWXYZ 91โ96 \x5Bโ\x60 \133โ\140
[\]^_` 0 โ 0 0 0 โ 0 โ 0 0
0 0 0 0 0 97โ102 \x61โ\x66 \141โ\146
abcdef 0 โ 0 0 0 โ 0 0 โ 0
โ 0 0 โ 0 0 โ 0 103โ122 \x67โ\x7A \147โ\172
ghijklmnop 0 โ 0 0 0 โ 0 0 โ 0
โ 0 0 โ 0 0 0
qrstuvwxyz 123โ126 \x7Bโ\x7E \172โ\176
{|}~ 0 โ 0 0 0 โ 0 โ 0 0
0 0 0 0 0 127 \x7F \177
backspace โ 0 0 0 0 0 0 0
0 0 0 0 0
character (DEL)
Okay that's the whole page, bestie. Footer realness, because we do not skip the boring bits: source/version is http://cppreference.com, date is 2024.06.10, and the manual page is std::iswalpha(3). Mwah ๐โจ
๐ฆ 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