在线文档教程
C++
本土化 | Localizations

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!'

二次

另见

toupperinvokes do_toupper (public member function)
tolowerconverts a character to lowercase (function)
towlowerconverts a wide character to lowercase (function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/locale/ctype/tolower