towupper

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

若可能则转换给定的宽字符为大写。

参数

ch - 要转换的宽字符

返回值

ch 的大写版本,或若无大写版本列于当前 C 本地环境,则为不修改的 ch

注意

此函数只能进行 1:1 映射,例如 'ß' 的大写形式(有一些例外)是双字符字符串 "SS" ,它无法通过 towupper 获得。

ISO 30112 指定此映射包含哪些 Unicode 字符对。

示例

#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include <locale.h>
 
int main(void)
{
    wchar_t wc =  L'\u017f'; // 拉丁文小写字母长 S ('ſ')
    printf("in the default locale, towupper(%#x) = %#x\n", wc, towupper(wc));
    setlocale(LC_ALL, "en_US.utf8");
    printf("in Unicode locale, towupper(%#x) = %#x\n", wc, towupper(wc));
}

输出:

in the default locale, towupper(0x17f) = 0x17f
in Unicode locale, towupper(0x17f) = 0x53

引用

  • C11 standard (ISO/IEC 9899:2011):
  • 7.30.3.1.2 The towupper function (p: 453)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.25.3.1.2 The towupper function (p: 399)

参阅

将宽字符转换为小写
(函数)
将字符转换成大写
(函数)