std::iswprint(3)
π std::iswprint β C++ Standard Library π
okay bestie, this is thestd::iswprint(3)page, and we're reading it like a group chat. The manual name is folded right in:std::iswprint, C++ Standard Library. Periodt. π
πΈ NAME πΈ
std::iswprint - std::iswprint
β¨ Synopsis β¨
Defined in header <cwctype>:
int iswprint( std::wint_t ch );
So std::iswprint checks if the given wide character can be printed. That means it's either a number (0123456789), an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), a lowercase letter (abcdefghijklmnopqrstuvwxyz), a punctuation character from this exact set:
!"#$%&'()*+,-./:;<=>?@[\]^_`{!}~
or a space, or any printable character specific to the current C locale. Slay. β¨
π¨ UNDEFINED BEHAVIOR ALERT π¨ If the value ofchis neither representable as awchar_tnor equal to the value of the macroWEOF, the behavior is undefined. No cap, do not pass that vibe. π
π Parameters π
chβ wide character. That's the whole parameter, bestie. π«Ά
π Return value π
Non-zero value if the wide character can be printed, zero otherwise. Simple as that. π
π§ Notes π§
ISO 30112 specifies which Unicode characters are include in POSIX print category. That's the lore drop, bestie. π§
πΈ Example πΈ
Run this code, literally:
#include <clocale>
#include <cwctype>
#include <iostream>
void demo_iswprint(std::string_view rem, const std::wint_t c)
{
std::cout << std::boolalpha << std::hex << std::showbase
<< rem << "iswprint('" << c << "') = "
<< !!std::iswprint(c) << '\n';
}
int main()
{
const wchar_t c1 = L'\u2002'; // en-space
const wchar_t c2 = L'\u0082'; // break permitted
demo_iswprint("In default locale:\n", c1);
std::setlocale(LC_ALL, "en_US.utf8");
demo_iswprint("In Unicode locale:\n", c1);
demo_iswprint("", c2);
}
π¦ Possible output π¦
In default locale:
iswprint('0x2002') = false
In Unicode locale:
iswprint('0x2002') = true
iswprint('0x82') = false
π See also π
isprint(std::locale)β checks if a character is classified as printable by a locale (function template)isprintβ checks if a character is a printing character (function)- C documentation for
iswprint
π ASCII values table (verbatim) π
Here's the iconic ASCII values table, exactly as the page gives it β all of it, bestie, we don't skip lore:
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)
π That's the whole page, bestie! Source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::iswprint(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