std::iswblank(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay so bestie, this is the std::iswblank(3) page from the C++ Standard Libary β€” yes, that’s literally how the header spells it, iconic β€” and we’re gonna read it together like the main-character documentation it is πŸ’…βœ¨

πŸ’– NAME πŸ’–

std::iswblank β€” literally std::iswblank. That’s the name, no cap. 🫢

✨ Synopsis ✨

Defined in header <cwctype>:

int iswblank( std::wint_t ch );  (since C++11)

So what does it do? It checks if the given wide character is classified as a blank character β€” and yes, that means a whitespace character used to separate words in a sentence β€” by the current C locale. In the default C locale, only space (0x20) and horizontal tab (0x09) are blank characters. πŸŽ€

⚠️ Danger zone, bestie: 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. Like, don’t do that. πŸ’€

🌸 Parameters 🌸

  • ch β€” wide character. That’s the whole parameter list, iconic and minimal. πŸ’–

⭐ Return value ⭐

Non-zero value if the wide character is a blank character, zero otherwise. Simple as that. ✨

πŸ¦‹ Notes πŸ¦‹

ISO 30112 defines POSIX blank characters as Unicode characters U+0009, U+0020, U+1680, U+180E, U+2000..U+2006, U+2008, U+200A, U+205F, and U+3000. So yes, there are way more blank-ish characters in the Unicode universe. 🌈

πŸŽ€ Example πŸŽ€

Run this code (the comment literally says // Run this code):

// Run this code

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

int main()
{
    wchar_t c = L'\u3000'; // Ideographic space ('  ')

    std::cout << std::hex << std::showbase << std::boolalpha;
    std::cout << "in the default locale, iswblank(" << (std::wint_t)c
              << ") = "
              << (bool)std::iswblank(c) << '\n';
    std::setlocale(LC_ALL, "en_US.utf8");
    std::cout << "in Unicode locale, iswblank(" << (std::wint_t)c << ") = "
              << (bool)std::iswblank(c) << '\n';
}

πŸ’œ Output πŸ’œ

in the default locale, iswblank(0x3000) = false
in Unicode locale, iswblank(0x3000) = true

πŸ”₯ See also πŸ”₯

  • isblank(std::locale) β€” checks if a character is classified as a blank character by a locale (C++11) (function template) 🫢
  • isblank β€” checks if a character is a blank character (C++11) (function) ✨
  • C documentation for iswblank β€” yes, the C version, go off. πŸ’…

🌈 ASCII values chart (the iconic table) 🌈

okay so the page also has this big ASCII values table, and the header names these columns: 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. The rows below carry the twelve classification values exactly as the page prints them, bestie. πŸŽ€

decimal  hexadecimal  octal     characters                     iscntrl isprint isspace isblank isgraph ispunct isalnum isalpha isupper islower isdigit isxdigit
0–8      \x0–\x8      \0–\10    control codes (NUL, etc.)      β‰ 0      0       0       0       0       0       0       0       0       0       0       0
9        \x9          \11       tab (\t)                       β‰ 0      0       β‰ 0      β‰ 0      0       0       0       0       0       0       0       0
10–13    \xA–\xD      \12–\15   whitespaces (\n, \v, \f, \r)   β‰ 0      0       β‰ 0      0       0       0       0       0       0       0       0       0
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 GHIJKLMNOPQRSTUVWXYZ           0       β‰ 0      0       0       β‰ 0      0       β‰ 0      β‰ 0      β‰ 0      0       0       0
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 ghijklmnopqrstuvwxyz           0       β‰ 0      0       0       β‰ 0      0       β‰ 0      β‰ 0      0       β‰ 0      0       0
123–126  \x7B–\x7E    \172–\176 {|}~                           0       β‰ 0      0       0       β‰ 0      β‰ 0      0       0       0       0       0       0
127      \x7F         \177      backspace character (DEL)      β‰ 0      0       0       0       0       0       0       0       0       0       0       0

and finally, shoutout to the footer, bestie: source/version http://cppreference.com, date 2024.06.10, manual tag std::iswblank(3) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from