std::iscntrl(std::locale)(3)

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

✨ NAME ✨

Okay bestie, this is the std::iscntrl(std::locale)(3) page, and the manual name is the C++ Standard Libary β€” folded in right here near the top instead of a copied header line, periodt. The function name is std::iscntrl(std::locale), and the page name is std::iscntrl(std::locale)(3). We're doing this. πŸ’…


🌸 Synopsis 🌸

Defined in header <locale> β€” yes, it's giving header energy.

template< class CharT >
bool iscntrl( CharT ch, const locale& loc );

Checks if the given character is classified as a control character by the given locale's std::ctype facet. That's the whole vibe check. πŸ¦‹


πŸŽ€ Parameters πŸŽ€

  • ch β€” character
  • loc β€” locale

πŸ’– Return value πŸ’–

Returns true if the character is classified as a control character, false otherwise. No cap, that's the tea. ✨


🧚 Possible implementation 🧚

Here's the possible implementation exactly as the page gives it:

template<class CharT>
bool iscntrl(CharT ch, const std::locale& loc)
{
    return
    std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::cntrl, ch);
}

πŸ“ Example πŸ“

This demonstrates the use of iscntrl() with different locales β€” and yes, it's OS-specific, bestie. 🫢

// Run this code

#include <iostream>
#include <locale>

int main()
{
    const wchar_t CCH = L'\u0094'; // Destructive Backspace in Unicode

    std::locale loc1("C");
    std::cout << "iscntrl(CCH, C locale) returned "
              << std::boolalpha << std::iscntrl(CCH, loc1) << '\n';

    std::locale loc2("en_US.UTF8");
    std::cout << "iscntrl(CCH, Unicode locale) returned "
              << std::boolalpha << std::iscntrl(CCH, loc2) << '\n';
}

πŸ‘‘ Possible output πŸ‘‘

iscntrl(CCH, C locale) returned false
iscntrl(CCH, Unicode locale) returned true

πŸ¦‹ See also πŸ¦‹

  • iscntrl β€” checks if a character is a control character (function)
  • iswcntrl β€” checks if a wide character is a control character (function)

Source/version/date tea β˜•: http://cppreference.com Β· 2024.06.10 Β· std::iscntrl(std::locale)(3) β€” bye bestie, slay your locale checks πŸ’…βœ¨

πŸ“¦ where this page comes from