在线文档教程
C++
本土化 | Localizations

std::ctype::do_toupper

STD::Ctype::Touch,STD::Ctype::Do[医]触头

Defined in header
public: CharT toupper( CharT c ) const;(1)
public: const CharT* toupper( CharT* beg, const CharT* end ) const;(2)
protected: virtual CharT do_toupper( CharT c ) const;(3)
protected: virtual const CharT* do_toupper( CharT* beg, const CharT* end ) const;(4)

1,2%29的公共成员函数,调用受保护的虚拟成员函数。do_toupper最派生的类。

3%29转换字符c如果大写窗体由此区域设置定义,则为大写。

4%29对字符数组中的每个字符[beg, end),如果存在大写形式,则将字符替换为该大写形式。

参数

c-character to convert
beg-pointer to the first character in an array of characters to convert
end-one past the end pointer for the array of characters to convert

返回值

1,3%29大写字符或c如果此区域设置没有列出大写形式。

2,4%29end...

注记

这个函数只能执行01:1的字符映射,例如,大写形式%27%27是%28,但有一些例外,即双字符字符串“ss”,它不能由do_toupper...

二次

#include <locale> #include <iostream> void try_upper(const std::ctype<wchar_t>& f, wchar_t c) { wchar_t up = f.toupper(c if (up != c) { std::wcout << "Upper case form of \'" << c << "' is " << up << '\n'; } else { std::wcout << '\'' << c << "' has no upper case form\n"; } } int main() { std::locale::global(std::locale("en_US.utf8") std::wcout.imbue(std::locale() std::wcout << "In US English UTF-8 locale:\n"; auto& f = std::use_facet<std::ctype<wchar_t>>(std::locale() try_upper(f, L's' try_upper(f, L'ſ' try_upper(f, L'ß' std::wstring str = L"Hello, World!"; std::wcout << "Uppercase form of the string '" << str << "' is "; f.toupper(&str[0], &str[0] + str.size() std::wcout << "'" << str << "'\n"; }

二次

产出:

二次

In US English UTF-8 locale: Upper case form of 's' is S Upper case form of 'ſ' is S 'ß' has no upper case form Uppercase form of the string 'Hello, World!' is 'HELLO, WORLD!'

二次

另见

tolowerinvokes do_tolower (public member function)
toupperconverts a character to uppercase (function)
towupperconverts a wide character to uppercase (function)

© cppreference.com

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

http://en.cppreference.com/w/cpp/locale/ctype/touper