std::iswctype(3)
π std::iswctype π
okay so we're in the C++ Standard Libary manual β yes, bestie, that's the manual name from the header, typo and all, and we're keeping it because it's iconic π
. This page is all about std::iswctype, and it's lowkey a little classification queen. π
πΈ NAME πΈ
std::iswctype β std::iswctype
yes, that's literally the whole NAME line, no notes, we move. π¦
β¨ Synopsis β¨
Defined in header <cwctype>
int iswctype( std::wint_t wc, std::wctype_t desc );
It classifies the wide character wc using the current C locale's LC_CTYPE category identified by desc. So it's like, "hey, what kind of character is this?" energy. π₯
π¨ If the value ofwcis neither representable as awchar_tnor equal to the value of the macroWEOF, the behavior is undefined. That's not a vibe, bestie β it's literally undefined behavior. π
π Parameters π
wcβ the wide character to classifydescβ theLC_CTYPEcategory, obtained from a call tostd::wctype
cute little duo, honestly. π«Ά
π Return value π
Non-zero if the character wc has the property identified by desc in the LC_CTYPE facet of the current C locale, zero otherwise. So it's giving yes-or-no, true-or-false, slay-or-nay. β
π§ Example π§
// Run this code
#include <clocale>
#include <cwctype>
#include <iostream>
bool classify(wchar_t wc, const std::string& cat)
{
return std::iswctype(wc, std::wctype(cat.c_str()));
}
int main()
{
std::setlocale(LC_ALL, "ja_JP.UTF-8");
std::cout << "The character \u6c34 is...\n";
for (std::string s : {"digit", "alpha", "space", "cntrl",
"jkanji"})
std::cout << s << "? " << std::boolalpha << classify(L'\u6c34',
s) << '\n';
}
this example sets the locale to ja_JP.UTF-8 and then checks what the character ζ°΄ is, category by category. the way that jkanji just says true at the end? obsessed. π
π» Output π»
The character ζ°΄ is...
digit? false
alpha? true
space? false
cntrl? false
jkanji? true
look at that iconic little truth table. alpha? true, jkanji? true, and the rest are like "no bestie". π
πΈ See also πΈ
wctypeβ looks up a character classification category in the current C locale (function)- C documentation for
iswctype
go check those out if you want the full lore, iykyk. π¦
okay bye bestie π«Ά β this page is from http://cppreference.com, dated 2024.06.10, and it's std::iswctype(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