| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
ctype::tolowerctype::do_tolower | ||||
| Member functions of ctype<char> | ||||
Defined in header <locale> | ||
public: CharT tolower( CharT c)const; | (1) | |
public: const CharT* tolower( CharT* beg,const CharT* end)const; | (2) | |
protected: virtual CharT do_tolower( CharT c)const; | (3) | |
protected: virtualconst CharT* do_tolower( CharT* beg,const CharT* end)const; | (4) | |
do_tolower of the most derived class.[beg, end), for which a lower case form exists, replaces the character with that lower case form.Contents |
| c | - | character to convert |
| beg | - | pointer to the first character in an array of characters to convert |
| end | - | one past the end pointer for the array of characters to convert |
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 todo_tolower cannot be used to obtain the correct lowercase form in this case.
#include <iostream>#include <locale> void try_lower(conststd::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';elsestd::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";}
Output:
In US English UTF-8 locale:Lower case form of 'Σ' is σLower case form of 'Ɛ' is ɛLower case form of 'A' is aLowercase form of the string 'HELLo, wORLD!' is 'hello, world!'
invokesdo_toupper(public member function)[edit] | |
| converts a character to lowercase (function)[edit] | |
| converts a wide character to lowercase (function)[edit] |