首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::ctype::do_tolower

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: 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在这种情况下,无法使用它获得正确的小写形式。

二次

代码语言:javascript
复制
#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";
}

二次

产出:

二次

代码语言:javascript
复制
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)

代码语言:txt
复制
 ? cppreference.com

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com