在线文档教程
C++
字符串 | Strings

std::toupper

STD::Touch

Defined in header
int toupper( int ch

根据当前安装的C语言环境定义的字符转换规则,将给定字符转换为大写字符。

在默认的“C”区域设置中,以下小写字母abcdefghijklmnopqrstuvwxyz被相应的大写字母替换。ABCDEFGHIJKLMNOPQRSTUVWXYZ...

参数

ch-character to be converted. If the value of ch is not representable as unsigned char and does not equal EOF, the behavior is undefined.

返回值

转换字符或ch如果当前C语言环境没有定义大写版本。

二次

#include <iostream> #include <cctype> #include <clocale> int main() { unsigned char c = '\xb8'; // the character ž in ISO-8859-15 // but ¸ (cedilla) in ISO-8859-1 std::setlocale(LC_ALL, "en_US.iso88591" std::cout << std::hex << std::showbase; std::cout << "in iso8859-1, toupper('0xb8') gives " << std::toupper(c) << '\n'; std::setlocale(LC_ALL, "en_US.iso885915" std::cout << "in iso8859-15, toupper('0xb8') gives " << std::toupper(c) << '\n'; }

二次

产出:

二次

in iso8859-1, toupper('0xb8') gives 0xb8 in iso8859-15, toupper('0xb8') gives 0xb4

二次

另见

tolowerconverts a character to lowercase (function)
toupper(std::locale)converts a character to uppercase using the ctype facet of a locale (function template)
towupperconverts a wide character to uppercase (function)

C文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/字节/touper