towupper
From cppreference.net
Null-terminated wide strings
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<wctype.h>
|
||
|
wint_t towupper
(
wint_t wc
)
;
|
(C95 起) | |
将给定的宽字符转换为大写形式(如果可能)。
目录 |
参数
| wc | - | 待转换的宽字符 |
返回值
wc
的大写版本,若当前 C 本地化设置中未列出大写形式则返回未修改的
wc
。
注释
该函数仅能执行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'; // Latin small letter Long 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