std::ctype<CharT>:: toupper, std::ctype<CharT>:: do_toupper
From cppreference.net
|
ヘッダーで定義
<locale>
|
||
|
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)
パブリックメンバー関数。最も派生したクラスの保護された仮想メンバー関数
do_toupper
を呼び出す。
3)
このロケールで大文字形式が定義されている場合、文字
c
を大文字に変換します。
4)
文字配列
[
beg
,
end
)
内の各文字について、大文字形式が存在する場合、その文字を大文字形式で置き換えます。
目次 |
パラメータ
| c | - | 変換する文字 |
| beg | - | 変換対象の文字配列の先頭文字へのポインタ |
| end | - | 変換対象の文字配列の終端(末尾の次)を指すポインタ |
戻り値
1,3)
大文字または
c
このロケールで大文字形式がリストされていない場合。
2,4)
end
注記
この関数は1:1の文字マッピングのみ実行可能です。例えば 'ß' の大文字形式は2文字の文字列 "SS" となります(一部の例外については
«Capital ẞ»
を参照)。これは
do_toupper
では取得できません。
例
このコードを実行
#include <iostream> #include <locale> 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'δ'); 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 Upper case form of 'δ' is Δ Upper case form of 'ö' is Ö 'ß' has no upper case form Uppercase form of the string 'Hello, World!' is 'HELLO, WORLD!'
関連項目
do_tolower
を呼び出す
(公開メンバ関数) |
|
|
文字を大文字に変換する
(関数) |
|
|
ワイド文字を大文字に変換する
(関数) |