Namespaces
Variants

towlower

From cppreference.net
< c ‎ | string ‎ | wide
定义于头文件 <wctype.h>
wint_t towlower ( wint_t wc ) ;
(C95 起)

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

目录

参数

wc - 待转换的宽字符

返回值

wc 的小写版本,若当前 C 区域设置中未列出小写版本则返回未修改的 wc

注释

此函数仅能执行1:1字符映射,例如希腊大写字母 'Σ' 根据在单词中的位置有两种小写形式: 'σ' 'ς' 。在此情况下无法通过调用 towlower 获取正确的小写形式。

ISO 30112 规定了哪些 Unicode 字符对包含在此映射中。

示例

#include <locale.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
int main(void)
{
    wchar_t wc = L'\u0190'; // 拉丁文大写开E ('Ɛ')
    printf("在默认区域设置中,towlower(%#x) = %#x\n", wc, towlower(wc));
    setlocale(LC_ALL, "en_US.utf8");
    printf("在Unicode区域设置中,towlower(%#x) = %#x\n", wc, towlower(wc));
}

输出:

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

参考文献

  • C23 标准 (ISO/IEC 9899:2024):
  • 7.30.3.1.1 towlower 函数 (p: TBD)
  • C17 标准 (ISO/IEC 9899:2018):
  • 7.30.3.1.1 towlower 函数 (p: TBD)
  • C11 标准 (ISO/IEC 9899:2011):
  • 7.30.3.1.1 towlower 函数 (p: 453)
  • C99标准(ISO/IEC 9899:1999):
  • 7.25.3.1.1 towlower 函数(页码:399)

参见

将宽字符转换为大写形式
(函数)
将字符转换为小写形式
(函数)
C++ documentation for towlower