Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/locale/islower"

From cppreference.com
< cpp‎ | locale
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh)
m (Example: Use Unicode/C++23 name for 'π' (i.e. capitalized), + `islower` VS `isupper`.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{cpp/title | islower{{small|(std::locale)}}}}
+
{{cpp/title|islower{{small|(std::locale)}}}}
 
{{cpp/locale/navbar}}
 
{{cpp/locale/navbar}}
 
+
{{ddcl|header=locale|
{{ddcl | header=locale |
+
template< class CharT >
template< class charT >
+
bool islower( CharT ch, const locale& loc );
bool islower( charT ch, const locale& loc );
+
 
}}
 
}}
 
+
Checks if the given character is classified as a lowercase alphabetic character by the given locale's {{lc|std::ctype}} facet.
 
+
Checks if the given character classified as a lowercase alphabetic character by the given locale's {{c|std::ctype}} facet.
+
  
 
===Parameters===
 
===Parameters===
{{param list begin}}
+
{{par begin}}
{{param list item | ch | character}}
+
{{par|ch|character}}
{{param list item | loc | locale }}
+
{{par|loc|locale}}
{{param list end}}
+
{{par end}}
  
 
===Return value===
 
===Return value===
 
 
Returns {{c|true}} if the character is classified as lowercase, {{c|false}} otherwise.
 
Returns {{c|true}} if the character is classified as lowercase, {{c|false}} otherwise.
  
 
===Possible implementation===
 
===Possible implementation===
 
{{eq fun
 
{{eq fun
| 1=
+
|1=
template< class charT >
+
template<class CharT>
bool islower( charT ch, const std::locale& loc ) {
+
bool islower(CharT ch, const std::locale& loc)
     return std::use_facet<std::ctype<charT>>(loc).is(std::ctype_base::lower, ch);
+
{
 +
     return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::lower, ch);
 
}
 
}
 
}}
 
}}
Line 31: Line 28:
 
===Example===
 
===Example===
 
{{example
 
{{example
| Demonstrates the use of islower() with different locales (OS-specific).
+
|Demonstrates the use of {{tt|islower()}} with different locales (OS-specific).
| code=
+
|code=
 
#include <iostream>
 
#include <iostream>
 
#include <locale>
 
#include <locale>
 +
 
int main()
 
int main()
 
{
 
{
     const wchar_t c = L'\u03c0'; // greek small letter pi
+
     const wchar_t c = L'\u03c0'; // GREEK SMALL LETTER PI
+
 
 
     std::locale loc1("C");
 
     std::locale loc1("C");
     std::cout << "islower('π​', C locale) returned "
+
     std::cout << std::boolalpha
              << std::boolalpha << std::islower(c, loc1) << '\n';
+
              << "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::locale loc2("en_US.UTF8");
     std::cout << "islower('π​', Unicode locale) returned "
+
     std::cout << "islower('π', Unicode locale) returned "
               << std::boolalpha << std::islower(c, loc2) << '\n';
+
               << std::islower(c, loc2) << '\n'
 +
              << "isupper('π', Unicode locale) returned "
 +
              << std::isupper(c, loc2) << '\n';
 
}
 
}
| output=
+
|p=true
islower('π​', C locale) returned false
+
|output=
islower('π​', Unicode locale) returned true
+
islower('π', C locale) returned false
 +
isupper('π', C locale) returned false
 +
islower('π', Unicode locale) returned true
 +
isupper('π', Unicode locale) returned false
 
}}
 
}}
  
 
===See also===
 
===See also===
{{dcl list begin}}
+
{{dsc begin}}
{{dcl list template | cpp/string/byte/dcl list islower}}
+
{{dsc inc|cpp/string/byte/dsc islower}}
{{dcl list template | cpp/string/wide/dcl list iswlower}}
+
{{dsc inc|cpp/string/wide/dsc iswlower}}
{{dcl list end}}
+
{{dsc end}}
  
[[de:cpp/locale/islower]]
+
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
[[es:cpp/locale/islower]]
+
[[fr:cpp/locale/islower]]
+
[[it:cpp/locale/islower]]
+
[[ja:cpp/locale/islower]]
+
[[pt:cpp/locale/islower]]
+
[[ru:cpp/locale/islower]]
+
[[zh:cpp/locale/islower]]
+

Latest revision as of 05:59, 4 October 2023

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

Checks if the given character is classified as a lowercase alphabetic character by the given locale's std::ctype facet.

Contents

[edit] Parameters

ch - character
loc - locale

[edit] Return value

Returns true if the character is classified as lowercase, false otherwise.

[edit] Possible implementation

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);
}

[edit] Example

Demonstrates the use of islower() with different locales (OS-specific).

#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

[edit] See also

checks if a character is lowercase
(function) [edit]
checks if a wide character is lowercase
(function) [edit]