std::isprint(std::locale)(3)

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

πŸ’– 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 β€” character
  • loc β€” 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