std::ctype<CharT>::tolower, std::ctype<CharT>::do_tolower
Min standard notice:
Header: <locale>
1,2) Public member function, calls the protected virtual member function do_tolower of the most derived class.
# Declarations
public:
CharT tolower( CharT c ) const;
public:
const CharT* tolower( CharT* beg, const CharT* end ) const;
protected:
virtual CharT do_tolower( CharT c ) const;
protected:
virtual const CharT* do_tolower( CharT* beg, const CharT* end ) const;
# Parameters
c: character to convertbeg: pointer to the first character in an array of characters to convertend: one past the end pointer for the array of characters to convert
# Notes
Only 1:1 character mapping can be performed by this function, e.g. the Greek uppercase letter ‘Σ’ has two lowercase forms, depending on the position in a word: ‘σ’ and ‘ς’. A call to do_tolower cannot be used to obtain the correct lowercase form in this case.
# Example
#include <iostream>
#include <locale>
void try_lower(const std::ctype<wchar_t>& f, wchar_t c)
{
wchar_t up = f.tolower(c);
if (up != c)
std::wcout << "Lower case form of \'" << c << "' is " << up << '\n';
else
std::wcout << '\'' << c << "' has no lower case form\n";
}
int main()
{
std::locale::global(std::locale("en_US.utf8"));
std::wcout.imbue(std::locale());
std::wcout << "In US English UTF-8 locale:\n";
auto& f = std::use_facet<std::ctype<wchar_t>>(std::locale());
try_lower(f, L'Σ');
try_lower(f, L'Ɛ');
try_lower(f, L'A');
std::wstring str = L"HELLo, wORLD!";
std::wcout << "Lowercase form of the string '" << str << "' is ";
f.tolower(&str[0], &str[0] + str.size());
std::wcout << '\'' << str << "'\n";
}