std::islower(std::locale)(3)

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

πŸŽ€ NAME πŸŽ€

okay bestie, welcome to std::islower(std::locale)(3) β€” yes, that's the title β€” from the C++ Standard Libary manual. This page is literally about std::islower(std::locale): the locale-aware lowercase check. No gatekeeping, we got you. πŸ’…

✨ Synopsis ✨

First things first, it's defined in header <locale> β€” say it with me. ✨

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

So what does it do? It checks if the given character is classified as a lowercase alphabetic character by the given locale's std::ctype facet. That's the whole vibe check. πŸ‘‘

🌸 Parameters 🌸

  • ch β€” character. that's the one we're checking, bestie.
  • loc β€” locale. this is the locale doing the classifying.

πŸ¦‹ Return value πŸ¦‹

Returns true if the character is classified as lowercase, false otherwise. periodt. βœ…

πŸ’– Possible implementation πŸ’–

Here's how it could look under the hood, no cap:

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

🌈 Example 🌈

Demonstrates the use of islower() with different locales (OS-specific). The original page also has a little // Run this code note. 🫢

#include <iostream>
#include <locale>

int main()
{
    const wchar_t c = L'\u03c0'; // GREEK SMALL LETTER PI

    std::locale loc1("C");
    std::cout << std::boolalpha
              << "islower('Ο€', C locale) returned "
              << std::islower(c, loc1) << '\n'
              << "isupper('Ο€', C locale) returned "
              << std::isupper(c, loc1) << '\n';

    std::locale loc2("en_US.UTF8");
    std::cout << "islower('Ο€', Unicode locale) returned "
              << std::islower(c, loc2) << '\n'
              << "isupper('Ο€', Unicode locale) returned "
              << std::isupper(c, loc2) << '\n';
}

πŸ“ Possible output πŸ“

islower('Ο€', C locale) returned false
isupper('Ο€', C locale) returned false
islower('Ο€', Unicode locale) returned true
isupper('Ο€', Unicode locale) returned false

πŸ‘‘ See also πŸ‘‘

  • islower β€” checks if a character is lowercase (function).
  • iswlower β€” checks if a wide character is lowercase (function).

and that's the whole page, bestie. source/version/date tea: http://cppreference.com, 2024.06.10, and std::islower(std::locale)(3). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from