function template
<locale>
std::tolower
template <class charT>
charT tolower (charT c, const locale& loc);
Convert uppercase letter to lowercase using locale
Converts parameter c to its lowercase equivalent if c is an uppercase letter and has a lowercase equivalent, as determined by the ctype facet of locale loc. If no such conversion is possible, the value returned is c unchanged.
This function returns the same as if ctype::tolower is called as:
|
use_facet < ctype<charT> > (loc).tolower (c)
|
This function template overloads the C function tolower (defined in <cctype>).
Parameters
- c
- Character to be converted.
- loc
- Locale to be used. It shall have a ctype facet.
The template argument charT is the character type.
Return Value
The lowercase equivalent to c, if any. Or c unchanged otherwise.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13
|
// tolower example (C++)
#include <iostream> // std::cout
#include <string> // std::string
#include <locale> // std::locale, std::tolower
int main ()
{
std::locale loc;
std::string str="Test String.\n";
for (std::string::size_type i=0; i<str.length(); ++i)
std::cout << std::tolower(str[i],loc);
return 0;
}
|
Output:
Data races
Both loc and its ctype facet are accessed.
Exception safety
Strong guarantee: if an exception is thrown, there are no effects.
See also
- ctype
- Character type facet (class template
)
- tolower (cctype)
- Convert uppercase letter to lowercase (function
)
- toupper
- Convert lowercase letter to uppercase using locale (function template
)
- isupper
- Check if character is an uppercase letter using locale (function template
)
- islower
- Check if character is a lowercase letter using locale (function template
)
- isalpha
- Check if character is alphabetic using locale (function template
)