towupper
来自 cppreference.cn
在头文件 <wctype.h> 中定义 |
||
wint_t towupper( wint_t wc ); |
(自 C95 起) | |
如果可能,将给定的宽字符转换为大写。
目录 |
[编辑] 参数
wc | - | 要转换的宽字符 |
[编辑] 返回值
如果当前 C 语言环境中没有列出 wc
的大写版本,则返回 wc
的大写版本或未修改的 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