命名空间
变体
操作

std::towlower

来自 cppreference.cn
< cpp‎ | string‎ | wide
定义于头文件 <cwctype>
std::wint_t towlower( std::wint_t ch );

将给定的宽字符转换为小写(如果可能)。

如果 ch 的值既不能表示为 wchar_t 也与宏 WEOF 的值不相等,则行为未定义。

目录

[编辑] 参数

ch - 要转换的宽字符

[编辑] 返回值

ch 的小写版本;如果当前 C 区域设置中没有列出小写版本,则为未修改的 ch

[编辑] 注意

此函数只能执行 1:1 字符映射,例如希腊语大写字母 'Σ' 有两种小写形式,具体取决于其在单词中的位置:'σ''ς'。在这种情况下,不能使用 std::towlower 来获取正确的小写形式。

ISO 30112 指定了此映射中包含的 Unicode 字符对。

[编辑] 示例

#include <clocale>
#include <cwctype>
#include <iostream>
 
int main()
{
    wchar_t c = L'\u0190'; // Latin capital open E ('Ɛ')
 
    std::cout << std::hex << std::showbase;
    std::cout << "in the default locale, towlower("
              << static_cast<std::wint_t>(c) << ") = "
              << std::towlower(c) << '\n';
    std::setlocale(LC_ALL, "en_US.utf8");
    std::cout << "in Unicode locale, towlower("
              << static_cast<std::wint_t>(c) << ") = "
              << std::towlower(c) << '\n';
}

输出

in the default locale, towlower(0x190) = 0x190
in Unicode locale, towlower(0x190) = 0x25b

[编辑] 参阅

将宽字符转换为大写
(函数) [编辑]
使用区域设置的 ctype 刻面将字符转换为小写
(函数模板) [编辑]
将字符转换为小写
(函数) [编辑]
C 文档,关于 towlower