std::isprint(std::locale)(3)
π std::isprint(std::locale)(3) π
okay so bestie, this is the std::isprint(std::locale)(3) page from the C++ Standard Libary β manual name folded in near the top, no cap. It's giving "does this character print?" energy and we're obsessed. π
β¨
πΈ NAME πΈ
std::isprint(std::locale) β std::isprint(std::locale)
Checks if the given character is classified as a printable character (including space) by the given locale's std::ctype facet.
β¨ Synopsis β¨
Defined in header <locale>
template< class CharT >
bool isprint( CharT ch, const locale& loc );
π Parameters π
chβ characterlocβ locale
π Return value π
Returns true if the character is classified as printable, false otherwise.
π§ Possible implementation π§
template<class CharT>
bool isprint(CharT ch, const std::locale& loc)
{
return
std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::print, ch);
}
π Example π
Demonstrates the use of isprint() with different locales (OS-specific).
The page literally says // Run this code, so here's the code, bestie:
#include <iostream>
#include <locale>
int main()
{
const wchar_t c = L'\u2122'; // trademark sign
std::locale loc1("C");
std::cout << "isprint('β’', C locale) returned "
<< std::boolalpha << std::isprint(c, loc1) << '\n';
std::locale loc2("en_US.UTF-8");
std::cout << "isprint('β’', Unicode locale) returned "
<< std::boolalpha << std::isprint(c, loc2) << '\n';
}
β Possible output β
isprint('β’', C locale) returned false
isprint('β’', Unicode locale) returned true
π¦ See also π¦
isprintβ checks if a character is a printing character (function)iswprintβ checks if a wide character is a printing character (function)
source/version: http://cppreference.com; date: 2024.06.10 β that's the cute little footer sign-off, bestie. This page ate and left no crumbs. πβ¨π
π¦ 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