std::ctype::do_tolower
STD::Ctype::Tolower,STD::Ctype::do[医]收费人
Defined in header | | |
---|---|---|
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: virtual const CharT* do_tolower( CharT* beg, const CharT* end ) const; | (4) | |
1,2%29的公共成员函数,调用受保护的虚拟成员函数。do_tolower
最派生的类。
3%29转换字符c
如果此区域设置定义了小写窗体,则为小写。
4%29对字符数组中的每个字符[beg, end)
,如果存在小写窗体,则将字符替换为该小写窗体。
参数
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 |
返回值
1,3%29小写字符或c
如果此区域设置没有列出小写窗体。
2,4%29end
...
注记
这个函数只能执行01:1的字符映射,例如,希腊大写字母%27Σ%27有两个小写形式,取决于单词中的位置:%27σ%27和%27%100。打电话给do_tolower
在这种情况下,无法使用它获得正确的小写形式。
例
二次
#include <locale>
#include <iostream>
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";
}
二次
产出:
二次
In US English UTF-8 locale:
Lower case form of 'Σ' is σ
Lower case form of 'Ɛ' is ɛ
Lower case form of 'A' is a
Lowercase form of the string 'HELLo, wORLD!' is 'hello, world!'
二次
另见
toupper | invokes do_toupper (public member function) |
---|---|
tolower | converts a character to lowercase (function) |
towlower | converts a wide character to lowercase (function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。