Namespaces
Variants

std:: towlower

From cppreference.net
定义于头文件 <cwctype>

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

如果 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'; // 拉丁文大写开E ('Ɛ')
    std::cout << std::hex << std::showbase;
    std::cout << "在默认区域设置中,towlower("
              << static_cast<std::wint_t>(c) << ") = "
              << std::towlower(c) << '\n';
    std::setlocale(LC_ALL, "en_US.utf8");
    std::cout << "在Unicode区域设置中,towlower("
              << static_cast<std::wint_t>(c) << ") = "
              << std::towlower(c) << '\n';
}

输出:

在默认区域设置中,towlower(0x190) = 0x190
在Unicode区域设置中,towlower(0x190) = 0x25b

参见

将宽字符转换为大写形式
(函数)
使用本地环境的 ctype 刻面将字符转换为小写形式
(函数模板)
将字符转换为小写形式
(函数)
C 文档 for towlower