Xi Xu's More Things

towupper

来自cppreference.com
< c‎ | string‎ | wide
 
 
 
空终止宽字符串
函数
字符操作
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C99)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
towupper
(C95)
(C95)
(C95)
转换成数值格式
(C95)(C99)
(C95)(C99)
(C99)(C95)(C99)
(C99)(C99)
字符串操作
(C95)(C11)
(C95)(C11)
(C95)(C11)
(C95)(C11)
(C95)(C11)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)
(C95)(C11)
数组操作
(C95)(C11)
(C95)(C11)
(C95)
(C95)
(C95)
 
在标头 <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 标准(ISO/IEC 9899:2011):
  • 7.30.3.1.2 The towupper function (第 453 页)
  • C99 标准(ISO/IEC 9899:1999):
  • 7.25.3.1.2 The towupper function (第 399 页)

参阅

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